Skip to content

Commit

Permalink
refactor : 리뷰 이미지 사이즈 변경
Browse files Browse the repository at this point in the history
- 리뷰 이미지는 1024 * 1024
- 프로필 이미지는 기존과 동일한 512 * 512

Co-authored-by: GeunH <[email protected]>
  • Loading branch information
LeeTH916 and GeunH committed Dec 14, 2023
1 parent bfe49c2 commit 182a05b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions be/src/aws/aws.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
6 changes: 3 additions & 3 deletions be/src/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 182a05b

Please sign in to comment.