|
1 | 1 | package umc.codeplay.domain.enums; |
2 | 2 |
|
3 | 3 | import umc.codeplay.dto.FileResponseDTO; |
4 | | -import umc.codeplay.service.FileService; |
5 | 4 |
|
6 | 5 | public enum FileType { |
7 | 6 | AUDIO { |
8 | | - public String getFolderName() { |
9 | | - return "requestFiles/"; |
10 | | - } |
11 | | - |
12 | | - public Long processUpload(FileService fileService, String fileName, String username) { |
13 | | - return fileService.uploadMusic(fileName, username); |
14 | | - } |
15 | | - |
16 | | - public FileResponseDTO.UploadFile createResponse(String uploadUrl, Long id) { |
17 | | - return new FileResponseDTO.UploadFile(uploadUrl, id, null); |
| 7 | + @Override |
| 8 | + public String buildStoragePath(Long id, String fileName) { |
| 9 | + return String.format("%s%d/%s", BASE_AUDIO_PATH, id, fileName); |
18 | 10 | } |
19 | 11 | }, |
20 | 12 | IMAGE { |
21 | | - public String getFolderName() { |
22 | | - return "profileImgs/"; |
23 | | - } |
24 | | - |
25 | | - public Long processUpload(FileService fileService, String fileName, String username) { |
26 | | - return fileService.uploadProfile(fileName, username); |
27 | | - } |
28 | | - |
29 | | - public FileResponseDTO.UploadFile createResponse(String uploadUrl, Long id) { |
30 | | - return new FileResponseDTO.UploadFile(uploadUrl, null, id); |
| 13 | + @Override |
| 14 | + public String buildStoragePath(Long id, String fileName) { |
| 15 | + return String.format("%s%d/%s", BASE_IMAGE_PATH, id, fileName); |
31 | 16 | } |
32 | 17 | }; |
33 | 18 |
|
34 | | - public abstract String getFolderName(); |
| 19 | + private static final String BASE_AUDIO_PATH = "requestFiles/"; |
| 20 | + private static final String BASE_IMAGE_PATH = "profileImgs/"; |
35 | 21 |
|
36 | | - public abstract Long processUpload(FileService fileService, String fileName, String username); |
| 22 | + public abstract String buildStoragePath(Long id, String fileName); |
37 | 23 |
|
38 | | - public abstract FileResponseDTO.UploadFile createResponse(String uploadUrl, Long id); |
| 24 | + public FileResponseDTO.UploadFile createResponse(String uploadUrl, Long id) { |
| 25 | + return this == AUDIO |
| 26 | + ? new FileResponseDTO.UploadFile(uploadUrl, id, null) |
| 27 | + : new FileResponseDTO.UploadFile(uploadUrl, null, id); |
| 28 | + } |
39 | 29 | } |
0 commit comments