Skip to content

Commit

Permalink
feat: 회원가입시 프로필 이미지가 null이라면 기본 이미지 url할당
Browse files Browse the repository at this point in the history
  • Loading branch information
khee2 committed Jul 30, 2024
1 parent 2c7f650 commit e3b442a
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,21 +136,23 @@ public void signUpMember(SignupRequestDto signupRequestDto, MultipartFile profil
// 회원 저장
memberRepository.save(newMember);

String profileImageUrl;
// 프로필 이미지 업로드 및 저장
if (profileImage != null && !profileImage.isEmpty()) {
try {
String profileImageUrl = getS3UploadUrl(profileImage);
Image image = Image.builder()
.imageUrl(profileImageUrl)
.member(newMember)
.build();
imageRepository.save(image);
profileImageUrl = getS3UploadUrl(profileImage);
} catch (IOException e) {
log.error("프로필 이미지 업로드 실패: {}", e.getMessage());
// 이미지 업로드 실패 알림
throw new RuntimeException("프로필 이미지 업로드에 실패했습니다.");
}
} else { // null이라면 기본 프로필 이미지 할당
profileImageUrl = String.format("https://%s.s3.%s.amazonaws.com/%s", bucket, "ap-northeast-2", "profile-images/default_image.png");
}
Image image = Image.builder()
.imageUrl(profileImageUrl)
.member(newMember)
.build();
imageRepository.save(image);
}

/**
Expand Down

0 comments on commit e3b442a

Please sign in to comment.