Skip to content

Commit

Permalink
feat: ImageFileUploadService jpeg, webp 확장자 지원 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
seokjin8678 committed May 7, 2024
1 parent 9688d4e commit 4089b10
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
public class ImageFileUploadService {

private static final int MAX_FILE_SIZE = 2_000_000; // 2MB
private static final Set<FileExtension> ALLOW_IMAGE_EXTENSION = EnumSet.of(FileExtension.JPG, FileExtension.PNG);
private static final Set<FileExtension> ALLOW_IMAGE_EXTENSION = EnumSet.of(FileExtension.JPG, FileExtension.JPEG,
FileExtension.PNG, FileExtension.WEBP);

private final StorageClient storageClient;
private final UploadFileRepository uploadFileRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
@RequiredArgsConstructor
public enum FileExtension {
JPG(".jpg", MimeTypeUtils.IMAGE_JPEG),
JPEG(".jpeg", MimeTypeUtils.IMAGE_JPEG),
PNG(".png", MimeTypeUtils.IMAGE_PNG),
WEBP(".webp", new MimeType("image", "webp")),
NONE("", MimeTypeUtils.APPLICATION_OCTET_STREAM),
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void setUp() {
}

@ParameterizedTest
@ValueSource(strings = {"image.png", "image.jpg"})
@ValueSource(strings = {"image.png", "image.jpg", "image.jpeg", "image.webp"})
void 이미지를_업로드할때_JPG_PNG_확장자이면_성공한다(String filename) {
// given
MultipartFile multipartFile = new MockMultipartFile("image", filename, "image/png",
Expand Down

0 comments on commit 4089b10

Please sign in to comment.