|
7 | 7 | import com.amazonaws.services.s3.model.PutObjectRequest; |
8 | 8 | import com.team_nebula.nebula.global.apipayload.code.status.ErrorStatus; |
9 | 9 | import com.team_nebula.nebula.global.apipayload.exception.GeneralException; |
| 10 | +import com.team_nebula.nebula.global.util.HashUtil; |
10 | 11 | import lombok.RequiredArgsConstructor; |
11 | 12 | import lombok.extern.slf4j.Slf4j; |
12 | 13 | import org.springframework.beans.factory.annotation.Value; |
@@ -40,20 +41,21 @@ public String saveThumbnail(MultipartFile thumbnailImage, String dataInfo) { |
40 | 41 | return uploadThumbnailToS3(thumbnailImage, THUMBNAIL_DIR, dataInfo); |
41 | 42 | } |
42 | 43 |
|
43 | | - public String saveHtmlFile(MultipartFile htmlFile, String dataInfo) { |
44 | | - return uploadHtmlToS3(htmlFile, HTML_FILE_DIR, dataInfo); |
| 44 | + public String saveHtmlFile(MultipartFile htmlFile, String dataInfo, Long userId) { |
| 45 | + return uploadHtmlToS3(htmlFile, HTML_FILE_DIR, dataInfo, userId); |
45 | 46 | } |
46 | 47 |
|
47 | 48 | public String saveFavicon(File faviconFile, String domain) { |
48 | 49 | String fileName = FAVICON_FILE_DIR + domain + ".png"; |
49 | 50 | return uploadFileToS3(faviconFile, fileName); |
50 | 51 | } |
51 | 52 |
|
52 | | - private String uploadHtmlToS3(MultipartFile file, String dirName, String dataInfo) { |
| 53 | + private String uploadHtmlToS3(MultipartFile file, String dirName, String dataInfo, Long userId) { |
53 | 54 | File uploadFile = convert(file) |
54 | 55 | .orElseThrow(() -> new GeneralException(ErrorStatus._MULTIPARTFILE_CONVERT_FAIL)); |
| 56 | + String hashUserId = HashUtil.hashUserId(userId); |
55 | 57 |
|
56 | | - String fileName = dirName + dataInfo + "/" + UUID.randomUUID() + "_" + file.getOriginalFilename(); |
| 58 | + String fileName = dirName + hashUserId + "/" + dataInfo + "/" + UUID.randomUUID() + "_" + file.getOriginalFilename(); |
57 | 59 |
|
58 | 60 | putHtmlS3(uploadFile, fileName); |
59 | 61 | removeNewFile(uploadFile); |
|
0 commit comments