Skip to content

Commit

Permalink
Merge pull request #82 from Na-o-man/fix/#81/photo-fix
Browse files Browse the repository at this point in the history
[FIX] 사진 업로드, 조회시 발생하는 버그 수정
  • Loading branch information
bflykky authored Aug 11, 2024
2 parents bf81984 + 556950e commit 7b6c724
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -64,18 +65,19 @@ public PhotoResponse.PagedPhotoEsInfo toPagedPhotoEsInfo(Page<PhotoEs> photoEsLi
public PhotoResponse.PhotoEsInfo toPhotoEsInfo(PhotoEs photoEs, Member member) {
String rawUrl = photoEs.getUrl();
Boolean isDownload = !photoEs.getDownloadTag().isEmpty() && photoEs.getDownloadTag().contains(member.getId());
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime createdAt = LocalDateTime.parse(photoEs.getCreatedAt(), dateTimeFormatter);

return PhotoResponse.PhotoEsInfo.builder()
.photoId(photoEs.getRdsId())
.rawPhotoUrl(rawUrl)
.w200PhotoUrl(createResizedPhotoUrl(rawUrl, W200_PATH_PREFIX))
.w400PhotoUrl(createResizedPhotoUrl(rawUrl, W400_PATH_PREFIX))
.isDownload(isDownload)
.createdAt(LocalDateTime.parse(photoEs.getCreatedAt()))
.createdAt(createdAt)
.build();
}


private String createResizedPhotoUrl(String photoUrl, String size) {
String resizedUrl = getResizedUrl(photoUrl, size);
return convertExtension(resizedUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private String extractPhotoNameFromUrl(String photoUrl) {

// S3에 객체의 존재 여부 확인 및 DB에 사진을 저장하고 객체를 반환하는 메서드
private Photo checkAndSavePhotoInDB(String photoUrl, String photoName, ShareGroup shareGroup) {
if (amazonS3.doesObjectExist(bucketName, RAW_PATH_PREFIX + "/" + photoName)) {
if (!amazonS3.doesObjectExist(bucketName, RAW_PATH_PREFIX + "/" + photoName)) {
throw new BusinessException(PHOTO_NOT_FOUND_S3);
}

Expand Down

0 comments on commit 7b6c724

Please sign in to comment.