diff --git a/src/main/java/com/leets/xcellentbe/domain/article/service/S3UploadMediaService.java b/src/main/java/com/leets/xcellentbe/domain/article/service/S3UploadMediaService.java index 55d8c86..91519bd 100644 --- a/src/main/java/com/leets/xcellentbe/domain/article/service/S3UploadMediaService.java +++ b/src/main/java/com/leets/xcellentbe/domain/article/service/S3UploadMediaService.java @@ -30,12 +30,13 @@ public class S3UploadMediaService { public String upload(MultipartFile multipartFile, String dirName) { String fileName = multipartFile.getOriginalFilename(); - if (!(fileName.endsWith(".png") || fileName.endsWith(".jpg"))) { + if (!(fileName.endsWith(".png") || fileName.endsWith(".jpg") || fileName.endsWith(".jpeg") || fileName.endsWith( + ".gif") || fileName.endsWith(".bmp"))) { throw new InvalidFileFormat(); } try { File uploadFile = convert(multipartFile) - .orElseThrow(()->new RuntimeException()); + .orElseThrow(() -> new RuntimeException()); return upload(uploadFile, dirName); } catch (IOException e) { throw new InternalServerErrorException(); diff --git a/src/main/java/com/leets/xcellentbe/domain/user/service/S3UploadService.java b/src/main/java/com/leets/xcellentbe/domain/user/service/S3UploadService.java index 91af467..bbd6875 100644 --- a/src/main/java/com/leets/xcellentbe/domain/user/service/S3UploadService.java +++ b/src/main/java/com/leets/xcellentbe/domain/user/service/S3UploadService.java @@ -30,7 +30,8 @@ public class S3UploadService { // MultipartFile을 전달받아 File로 전환한 후 S3에 업로드 public String upload(MultipartFile multipartFile, String dirName) { // dirName의 디렉토리가 S3 Bucket 내부에 생성됨 String fileName = multipartFile.getOriginalFilename(); - if ((fileName.endsWith(".png") || fileName.endsWith(".jpg"))) { + if (!(fileName.endsWith(".png") || fileName.endsWith(".jpg") || fileName.endsWith(".jpeg") || fileName.endsWith( + ".gif") || fileName.endsWith(".bmp"))) { throw new InvalidFileFormat(); }