mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
refactor(server): immich file responses (#5641)
* refactor(server): immich file response * chore: open api * chore: tests * chore: fix logger import --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
parent
af7c4ae090
commit
cbca69841a
25 changed files with 186 additions and 154 deletions
|
|
@ -3,7 +3,6 @@ import {
|
|||
AssetResponseDto,
|
||||
AuthDto,
|
||||
BulkIdResponseDto,
|
||||
ImmichReadStream,
|
||||
MergePersonDto,
|
||||
PeopleResponseDto,
|
||||
PeopleUpdateDto,
|
||||
|
|
@ -13,16 +12,12 @@ import {
|
|||
PersonStatisticsResponseDto,
|
||||
PersonUpdateDto,
|
||||
} from '@app/domain';
|
||||
import { Body, Controller, Get, Param, Post, Put, Query, StreamableFile } from '@nestjs/common';
|
||||
import { ApiOkResponse, ApiTags } from '@nestjs/swagger';
|
||||
import { Auth, Authenticated } from '../app.guard';
|
||||
import { Body, Controller, Get, Param, Post, Put, Query } from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { Auth, Authenticated, FileResponse } from '../app.guard';
|
||||
import { UseValidation } from '../app.utils';
|
||||
import { UUIDParamDto } from './dto/uuid-param.dto';
|
||||
|
||||
function asStreamableFile({ stream, type, length }: ImmichReadStream) {
|
||||
return new StreamableFile(stream, { type, length });
|
||||
}
|
||||
|
||||
@ApiTags('Person')
|
||||
@Controller('person')
|
||||
@Authenticated()
|
||||
|
|
@ -74,13 +69,9 @@ export class PersonController {
|
|||
}
|
||||
|
||||
@Get(':id/thumbnail')
|
||||
@ApiOkResponse({
|
||||
content: {
|
||||
'image/jpeg': { schema: { type: 'string', format: 'binary' } },
|
||||
},
|
||||
})
|
||||
@FileResponse()
|
||||
getPersonThumbnail(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto) {
|
||||
return this.service.getThumbnail(auth, id).then(asStreamableFile);
|
||||
return this.service.getThumbnail(auth, id);
|
||||
}
|
||||
|
||||
@Get(':id/assets')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue