Skip to content

Commit

Permalink
chore(s3): CloudFront에 캐싱된 이미지를 사용한다
Browse files Browse the repository at this point in the history
  • Loading branch information
0chil committed Nov 3, 2024
1 parent a81ae45 commit 8e7b389
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import java.util.stream.Collectors
class S3FileUploader(
@Value("\${cloud.aws.s3.bucket}")
private val bucket: String,
@Value("\${cloud.aws.cloudfront.domain}")
private val cloudFrontDomain: String,
private val amazonS3Client: AmazonS3
) {

Expand All @@ -35,7 +37,7 @@ class S3FileUploader(
it
}
amazonS3Client.putObject(bucket, key, resource.inputStream, metadata)
return amazonS3Client.getUrl(bucket, key)
return URL("https://$cloudFrontDomain/$key")
}

private fun uniquePathOf(resource: Resource): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ProfileImage {
private static final int MAXIMUM_URL_LENGTH = 255;

public static final ProfileImage EMPTY = new ProfileImage(
"https://snackgame.s3.ap-northeast-2.amazonaws.com/static/logo.png");
"https://d104q5gjwhhnfk.cloudfront.net/static/logo.png");

@Column(name = "profile_image", nullable = false)
private String url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MemberDetailsResponse(
@field:Schema(example = "닉네임")
val name: String,
val group: GroupResponse?,
@field:Schema(example = "https://snackgame.s3.ap-northeast-2.amazonaws.com/unhashed/7d9b26272791438b8dc6893a4cbd6f50-77423374")
@field:Schema(example = "https://d104q5gjwhhnfk.cloudfront.net/unhashed/7d9b26272791438b8dc6893a4cbd6f50-77423374")
val profileImage: String,
val status: StatusResponse,
@field:Schema(example = "SOCIAL", allowableValues = ["SELF", "GUEST", "SOCIAL"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class RankOwnerResponse {
private final Long id;
@Schema(example = "보리")
private final String name;
@Schema(example = "https://snackgame.s3.ap-northeast-2.amazonaws.com/unhashed/7d9b26272791438b8dc6893a4cbd6f50-77423374")
@Schema(example = "https://d104q5gjwhhnfk.cloudfront.net/unhashed/7d9b26272791438b8dc6893a4cbd6f50-77423374")
private final String profileImage;
private final StatusResponse status;
private final GroupResponse group;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/secrets

0 comments on commit 8e7b389

Please sign in to comment.