generated from Bamdoliro/repository-generator
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(#173): Presigned URL 파일 형식 및 크기 검증
- 증명사진, 원서 파일, 입학등록원 및 금연 서약서, 공지사항 파일을 업로드할 때 메타데이터를 전송하여 파일의 형식 및 크기를 검증할 수 있도록 하였습니다. - 전송한 메타데이터와 다른 파일을 보낼 경우 S3 Bucket에서 차단하도록 Presigned URL을 개선했습니다.
- Loading branch information
Showing
11 changed files
with
122 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/com/bamdoliro/maru/infrastructure/s3/dto/request/FileMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.bamdoliro.maru.infrastructure.s3.dto.request; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.springframework.http.MediaType; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class FileMetadata { | ||
|
||
@NotBlank(message = "필수값입니다.") | ||
private String fileName; | ||
|
||
@NotNull(message = "필수값입니다.") | ||
private MediaType mediaType; | ||
|
||
@NotNull(message = "필수값입니다.") | ||
private Long fileSize; | ||
} |
10 changes: 5 additions & 5 deletions
10
src/main/java/com/bamdoliro/maru/infrastructure/s3/validator/FileValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
package com.bamdoliro.maru.infrastructure.s3.validator; | ||
|
||
import com.bamdoliro.maru.infrastructure.s3.exception.EmptyFileException; | ||
import org.springframework.web.multipart.MultipartFile; | ||
import com.bamdoliro.maru.infrastructure.s3.dto.request.FileMetadata; | ||
|
||
@FunctionalInterface | ||
public interface FileValidator { | ||
void customValidate(MultipartFile file); | ||
void customValidate(FileMetadata request); | ||
|
||
default void validate(MultipartFile file) { | ||
if (file.isEmpty()) { | ||
default void validate(FileMetadata request) { | ||
if (request.getFileName().isBlank() || request.getFileName().lastIndexOf(".") == -1) { | ||
throw new EmptyFileException(); | ||
} | ||
|
||
customValidate(file); | ||
customValidate(request); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
src/main/java/com/bamdoliro/maru/presentation/notice/dto/request/UploadFileRequest.java
This file was deleted.
Oops, something went wrong.