-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from KONKUK-MAP-Service/feat-cloudfront
💡 [Feat] : 사진 응답속도 개선 #33
- Loading branch information
Showing
13 changed files
with
85 additions
and
13 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
44 changes: 44 additions & 0 deletions
44
src/main/java/com/cona/KUsukKusuk/global/s3/ImageUrlConverter.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,44 @@ | ||
package com.cona.KUsukKusuk.global.s3; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Component; | ||
|
||
|
||
@Component | ||
public class ImageUrlConverter { | ||
|
||
private static String s3BaseUrl; | ||
private static String cloudFrontBaseUrl; | ||
|
||
@Value("${cloud.aws.s3.bucketName}") | ||
public void setS3BaseUrl(String bucket) { | ||
s3BaseUrl = "https://" + bucket + ".s3.ap-northeast-2.amazonaws.com/"; | ||
} | ||
|
||
@Value("${cloud.aws.cloudfront.domainName}") | ||
public void setCloudFrontBaseUrl(String cloudfront) { | ||
cloudFrontBaseUrl = "https://" + cloudfront + "/"; | ||
} | ||
|
||
public static String convertToCloudFrontUrl(String imageUrl) { | ||
return imageUrl.replace(s3BaseUrl, cloudFrontBaseUrl); | ||
} | ||
|
||
public static List<String> convertToCloudFrontUrls(List<String> imageUrls) { | ||
return imageUrls.stream() | ||
.map(ImageUrlConverter::convertToCloudFrontUrl) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
public static String convertToS3Url(String imageUrl) { | ||
return imageUrl.replace(cloudFrontBaseUrl, s3BaseUrl); | ||
} | ||
|
||
public static List<String> convertToS3Urls(List<String> imageUrls) { | ||
return imageUrls.stream() | ||
.map(ImageUrlConverter::convertToS3Url) | ||
.collect(Collectors.toList()); | ||
} | ||
} |
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
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