Skip to content

Commit

Permalink
NB-193 : !HOTFIX - 프로필 이미지 경로 오류 수정
Browse files Browse the repository at this point in the history
프로필 이미지의 S3 업로드와 CDN URL 변환 과정에서 발생하는 경로 처리 오류를 수정함

문제 상황:
 - 업로드 경로의 시작이 "/"로 시작하지 않으면 CDN URL 변환 실패
 - 업로드 경로가 "/"로 시작하면 S3 버킷의 기존 구조와 불일치

해결 방법:
 - S3 업로드 시점에는 "/"를 제외하여 기존 경로 구조 유지
 - CDN URL 변환 시에만 "/" 추가하도록 로직 수정
  • Loading branch information
Aram-su committed Nov 12, 2024
1 parent de05903 commit 08ee906
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/soyeon/nubim/domain/user/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ public User findUserByIdOrThrow(Long userId) {
public ProfileImageUpdateResponse updateProfileImage(MultipartFile profileImage) {
validateProfileImageContentType(profileImage.getContentType());

String uploadPath = "/users/" + loggedInUserService.getCurrentUserId() + "/profile/" + UUID.randomUUID()
String uploadPath = "users/" + loggedInUserService.getCurrentUserId() + "/profile/" + UUID.randomUUID()
.toString()
.substring(0, 4);
String uploadResponse = s3ImageUploader.uploadImage(uploadPath, profileImage);

if (uploadResponse.contains("fail")) {
return new ProfileImageUpdateResponse("profile image update fail", null);
}
String cdnUrl = s3AndCdnUrlConverter.convertPathToCdnUrl(uploadPath);
String cdnUrl = s3AndCdnUrlConverter.convertPathToCdnUrl("/"+uploadPath);
userRepository.updateProfileImage(cdnUrl, loggedInUserService.getCurrentUserId());
return new ProfileImageUpdateResponse("profile image update success", uploadResponse);
}
Expand Down

0 comments on commit 08ee906

Please sign in to comment.