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.
- 서류 업로드 기능에 presigned url을 적용했습니다. - presigned url을 이용하면 서류를 조회할 때마다 새로운 presigned url을 요청해야하므로 Form 에서 formUrl 컬럼을 삭제했습니다.
- Loading branch information
Showing
8 changed files
with
27 additions
and
37 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
24 changes: 5 additions & 19 deletions
24
src/main/java/com/bamdoliro/maru/application/form/UploadFormUseCase.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,33 +1,19 @@ | ||
package com.bamdoliro.maru.application.form; | ||
|
||
import com.bamdoliro.maru.domain.user.domain.User; | ||
import com.bamdoliro.maru.infrastructure.s3.UploadFileService; | ||
import com.bamdoliro.maru.infrastructure.s3.FileService; | ||
import com.bamdoliro.maru.infrastructure.s3.constants.FolderConstant; | ||
import com.bamdoliro.maru.infrastructure.s3.dto.response.UploadResponse; | ||
import com.bamdoliro.maru.infrastructure.s3.exception.FileSizeLimitExceededException; | ||
import com.bamdoliro.maru.infrastructure.s3.exception.MediaTypeMismatchException; | ||
import com.bamdoliro.maru.infrastructure.s3.dto.response.UrlResponse; | ||
import com.bamdoliro.maru.shared.annotation.UseCase; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
import static com.bamdoliro.maru.shared.constants.FileConstant.MB; | ||
|
||
@RequiredArgsConstructor | ||
@UseCase | ||
public class UploadFormUseCase { | ||
|
||
private final UploadFileService uploadFileService; | ||
|
||
public UploadResponse execute(User user, MultipartFile formFile) { | ||
return uploadFileService.execute(formFile, FolderConstant.FORM, user.getUuid().toString(), file -> { | ||
if (file.getContentType() != null && !file.getContentType().equals(MediaType.APPLICATION_PDF_VALUE)) { | ||
throw new MediaTypeMismatchException(); | ||
} | ||
private final FileService fileService; | ||
|
||
if (file.getSize() > 20 * MB) { | ||
throw new FileSizeLimitExceededException(); | ||
} | ||
}); | ||
public UrlResponse execute(User user) { | ||
return fileService.getPresignedUrl(FolderConstant.FORM, user.getUuid().toString()); | ||
} | ||
} |
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