Skip to content

Commit f52c036

Browse files
authored
Merge pull request #85 from rhkr8521/fix/#add-bucket-cache
[FIX] Bucket - Cloudflare 연동
2 parents a0a2537 + cc03585 commit f52c036

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/main/java/com/rhkr8521/mapping/api/aws/s3/S3Service.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public class S3Service {
2727
@Value("${cloud.aws.s3.domain}")
2828
private String domain;
2929

30+
@Value("${cloud.aws.api.domain}")
31+
private String apiDomain;
32+
3033
public List<String> uploadMemoImages(String userIdentifier, List<MultipartFile> files) throws IOException {
3134
String dir = "memo-images";
3235
List<String> imageUrls = new ArrayList<>();
@@ -61,7 +64,7 @@ public List<String> uploadMemoImages(String userIdentifier, List<MultipartFile>
6164
// AWS S3
6265
//imageUrls.add(domain + "/" + fileKey);
6366
// rhkr8521-Bucket
64-
imageUrls.add(domain + "/" + bucketName + "/" + fileKey);
67+
imageUrls.add(apiDomain + "/" + bucketName + "/" + fileKey);
6568
}
6669

6770
return imageUrls;
@@ -93,16 +96,16 @@ public String uploadProfileImage(String email, MultipartFile file) throws IOExce
9396
// AWS S3
9497
//return domain + "/" + fileKey;
9598
// rhkr8521-Bucket
96-
return domain + "/" + bucketName + "/" + fileKey;
99+
return apiDomain + "/" + bucketName + "/" + fileKey;
97100

98101
}
99102

100103
public void deleteFile(String imageUrl) {
101-
if (imageUrl != null && imageUrl.startsWith(domain)) {
104+
if (imageUrl != null && imageUrl.startsWith(apiDomain)) {
102105
// AWS S3
103106
//String fileKey = imageUrl.replace(domain + "/", "");
104107
// rhkr8521-Bucket
105-
String fileKey = imageUrl.replace(domain + "/" + bucketName + "/", "");
108+
String fileKey = imageUrl.replace(apiDomain + "/" + bucketName + "/", "");
106109
DeleteObjectRequest deleteObjectRequest = DeleteObjectRequest.builder()
107110
.bucket(bucketName)
108111
.key(fileKey)

0 commit comments

Comments
 (0)