Skip to content

Commit

Permalink
Merge pull request #97 from Modagbul/feat/alarm_minsu
Browse files Browse the repository at this point in the history
hotfix: 마이페이지 오류 수정
  • Loading branch information
minsu20 authored Nov 29, 2023
2 parents 89acd6c + 2b4cc24 commit bf030f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.concurrent.CompletableFuture;

@Service
@RequiredArgsConstructor
Expand Down Expand Up @@ -41,8 +42,10 @@ private String getUpdatedValue(String newValue, String currentValue) {
}

private void deletePreviousImage(UpdateProfileRequest updateProfileRequest, Member member) {
if (updateProfileRequest.getProfileImage() != null) {
s3Service.deleteImage(member.getProfileImage());
if (updateProfileRequest.getProfileImage() != null && member.getProfileImage() != null) {
CompletableFuture.runAsync(() -> {
s3Service.deleteImage(member.getProfileImage());
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ public void deleteImage(String fileUrl) {
String splitStr = ".com/";
String fileName = fileUrl.substring(fileUrl.lastIndexOf(splitStr) + splitStr.length());

amazonS3.deleteObject(new DeleteObjectRequest(bucket, fileName));
if (amazonS3.doesObjectExist(bucket, fileName)) {
amazonS3.deleteObject(new DeleteObjectRequest(bucket, fileName));
}
}

private String createFileName(String fileExtension) {
private String createFileName(String fileExtension) {
return UUID.randomUUID() + "." + fileExtension;
}

Expand Down

0 comments on commit bf030f0

Please sign in to comment.