diff --git a/back/volume/src/users/users.controller.ts b/back/volume/src/users/users.controller.ts index 08d511f..bd2ec55 100644 --- a/back/volume/src/users/users.controller.ts +++ b/back/volume/src/users/users.controller.ts @@ -80,7 +80,7 @@ export class UsersController { @FtUser() profile: Profile, @UploadedFile() file: Express.Multer.File ) { - return await this.usersService.addAvatar(profile.id, file.filename) + await this.usersService.addAvatar(profile.id, file.filename) } @Get('avatar') @@ -89,15 +89,7 @@ export class UsersController { @FtUser() profile: Profile, @Res({ passthrough: true }) response: Response ){ - const user = await this.usersService.findUser(profile.id) - if (!user) return - const filename = user.avatar - const stream = createReadStream(join(process.cwd(), 'avatars/' + filename)) - response.set({ - 'Content-Diposition': `inline; filename="${filename}"`, - 'Content-Type': 'image/jpg' - }) - return new StreamableFile(stream) + return await this.getAvatarById(profile.id, response); } @Get('avatar/:id') diff --git a/back/volume/src/users/users.service.ts b/back/volume/src/users/users.service.ts index 21f090c..6073ba2 100644 --- a/back/volume/src/users/users.service.ts +++ b/back/volume/src/users/users.service.ts @@ -52,7 +52,7 @@ export class UsersService { } async addAvatar (ftId: number, filename: string) { - return await this.usersRepository.update(ftId, { + return await this.usersRepository.update({ftId}, { avatar: filename }) }