Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
@RestController
@RequiredArgsConstructor
@RequestMapping("/reviews")
@Tag(name = "Review")
@Tag(name = "리뷰" , description = "리뷰 관련 API")
@Validated
public class ReviewController {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,20 @@ public void saveReview(Long userId, Long placeId, ReviewRequestDTO.ReviewRegiste
likeRepository.save(newLike);
}

for (MultipartFile picture : reviewPictures) {
String uuid = UUID.randomUUID().toString();
Uuid savedUuid = uuidRepository.save(Uuid.builder()
.uuid(uuid).build());
if (reviewPictures != null && !reviewPictures.isEmpty()) {
for (MultipartFile picture : reviewPictures) {
String uuid = UUID.randomUUID().toString();
Uuid savedUuid = uuidRepository.save(Uuid.builder()
.uuid(uuid).build());

ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(picture.getSize());
metadata.setContentType(picture.getContentType());
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(picture.getSize());
metadata.setContentType(picture.getContentType());

String pictureUrl = s3Manager.uploadFile(s3Manager.generateReviewKeyName(savedUuid), savedUuid.getUuid(), picture, metadata);
String pictureUrl = s3Manager.uploadFile(s3Manager.generateReviewKeyName(savedUuid), savedUuid.getUuid(), picture, metadata);

mediaRepository.save(ReviewConverter.toReviewImage(pictureUrl, picture.getOriginalFilename(), picture.getContentType(), newReview));
mediaRepository.save(ReviewConverter.toReviewImage(pictureUrl, picture.getOriginalFilename(), picture.getContentType(), newReview));
}
}
} catch (DataIntegrityViolationException e) {
throw new BusinessException(ErrorStatus.REVIEW_SAVE_FAIL);
Expand Down