Skip to content

Commit

Permalink
refactor: 이미지 리스트 업로드 롤백 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
hgo641 committed Nov 22, 2023
1 parent c9d0b50 commit c53bec6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion backend/backend-submodule
9 changes: 6 additions & 3 deletions backend/src/main/java/hanglog/trip/service/ImageService.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package hanglog.trip.service;

import static hanglog.global.exception.ExceptionCode.EMPTY_IMAGE_LIST;
import static hanglog.global.exception.ExceptionCode.EXCEED_IMAGE_LIST_SIZE;
import static hanglog.global.exception.ExceptionCode.*;

import hanglog.global.exception.ImageException;
import hanglog.image.domain.ImageFile;
Expand Down Expand Up @@ -35,7 +34,11 @@ public ImagesResponse save(final List<MultipartFile> images) {

private List<String> uploadImages(final List<ImageFile> imageFiles) {
try {
return imageUploader.uploadImages(imageFiles);
final List<String> uploadedImageNames = imageUploader.uploadImages(imageFiles);
if(uploadedImageNames.size() != imageFiles.size()) {
throw new ImageException(INVALID_IMAGE_PATH);
}
return uploadedImageNames;
} catch (final ImageException e) {
imageFiles.forEach(imageFile -> publisher.publishEvent(new S3ImageEvent(imageFile.getHashedName())));
throw e;
Expand Down

0 comments on commit c53bec6

Please sign in to comment.