Skip to content

Commit

Permalink
fix: #31 파일 제약 확장
Browse files Browse the repository at this point in the history
  • Loading branch information
ehs208 committed Nov 13, 2024
1 parent bbb4c46 commit 61fe28a
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 @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit 61fe28a

Please sign in to comment.