diff --git a/be/src/aws/aws.service.ts b/be/src/aws/aws.service.ts index f4bd1e0..0285287 100644 --- a/be/src/aws/aws.service.ts +++ b/be/src/aws/aws.service.ts @@ -18,11 +18,11 @@ export class AwsService { }); } - async uploadToS3(path: string, data: Buffer) { + async uploadToS3(path: string, data: Buffer, size: number) { try { const resizedBuffer = await sharp(data) - .resize(512, 512) + .resize(size, size) .toBuffer(); await this.s3.putObject({ diff --git a/be/src/user/user.service.ts b/be/src/user/user.service.ts index 4f05177..5a45c77 100644 --- a/be/src/user/user.service.ts +++ b/be/src/user/user.service.ts @@ -51,7 +51,7 @@ export class UserService { const newUser = this.usersRepository.create(user); const result = await this.usersRepository.createUser(newUser); if (file) { - await this.awsService.uploadToS3(profileImage, file.buffer); + await this.awsService.uploadToS3(profileImage, file.buffer, 512); } return this.authService.createTokens(result.id); } catch (error) { @@ -363,7 +363,7 @@ export class UserService { restaurantId, reviewEntity ); - if (file) await this.awsService.uploadToS3(reviewImage, file.buffer); + if (file) await this.awsService.uploadToS3(reviewImage, file.buffer, 1024); } catch (err) { throw new BadRequestException(); } @@ -432,7 +432,7 @@ export class UserService { const newUser = this.usersRepository.create(user); const updatedUser = await this.usersRepository.updateMypageUserInfo(tokenInfo.id, newUser); if (file && isChanged) { - this.awsService.uploadToS3(profileImage, file.buffer); + this.awsService.uploadToS3(profileImage, file.buffer, 512); } return updatedUser; }