Skip to content

Commit a047d17

Browse files
committed
Fix: 파일 업로드 유효성 검사 수정
- multiparFile 필드 만 @NotNull로 지정
1 parent f5093dc commit a047d17

File tree

5 files changed

+3
-11
lines changed

5 files changed

+3
-11
lines changed

src/main/java/com/back/domain/file/dto/FileUpdateRequestDto.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ public class FileUpdateRequestDto {
1111
@NotNull(message = "파일 입력은 필수입니다.")
1212
private MultipartFile multipartFile;
1313

14-
@NotNull(message = "entityType은 필수입니다.")
1514
private EntityType entityType;
1615

17-
@NotNull(message = "entityId는 필수입니다.")
1816
private Long entityId;
1917
}

src/main/java/com/back/domain/file/dto/FileUploadRequestDto.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ public class FileUploadRequestDto {
1111
@NotNull(message = "파일 입력은 필수입니다.")
1212
private MultipartFile multipartFile;
1313

14-
@NotNull(message = "entityType은 필수입니다.")
1514
private EntityType entityType;
1615

17-
@NotNull(message = "entityId는 필수입니다.")
1816
private Long entityId;
1917
}

src/main/java/com/back/domain/file/dto/FileUploadResponseDto.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ public class FileUploadResponseDto {
99
public FileUploadResponseDto(String imageUrl) {
1010
this.imageUrl = imageUrl;
1111
}
12-
}
12+
}

src/main/java/com/back/domain/file/service/FileService.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ public FileUploadResponseDto uploadFile(
4949
new CustomException(ErrorCode.USER_NOT_FOUND)
5050
);
5151

52-
entityValidator.validate(entityType, entityId);
53-
5452
// S3에 저장할 파일 이름
5553
String storedFileName = createFileName(multipartFile.getOriginalFilename());
5654

@@ -78,8 +76,6 @@ public FileReadResponseDto getFile(
7876
EntityType entityType,
7977
Long entityId
8078
) {
81-
entityValidator.validate(entityType, entityId);
82-
8379
FileAttachment fileAttachment = getFileAttachmentOrThrow(entityType, entityId);
8480

8581
String filePath = fileAttachment.getFilePath();

src/test/java/com/back/domain/file/controller/FileControllerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void uploadFile_success() throws Exception {
6868

6969
String accessToken = generateAccessToken(user);
7070

71-
Post post = new Post(user, "첫 글", "내용");
71+
Post post = new Post(user, "첫 글", "내용", null);
7272
postRepository.save(post);
7373

7474
MockMultipartFile multipartFile = new MockMultipartFile(
@@ -105,7 +105,7 @@ void uploadFile_fail_noFile() throws Exception {
105105

106106
String accessToken = generateAccessToken(user);
107107

108-
Post post = new Post(user, "첫 글", "내용");
108+
Post post = new Post(user, "첫 글", "내용", null);
109109
postRepository.save(post);
110110

111111
// when

0 commit comments

Comments
 (0)