diff --git a/back/src/main/java/com/example/capstone/domain/qna/service/ImageService.java b/back/src/main/java/com/example/capstone/domain/qna/service/ImageService.java index a14f0702d7..61f1be7925 100644 --- a/back/src/main/java/com/example/capstone/domain/qna/service/ImageService.java +++ b/back/src/main/java/com/example/capstone/domain/qna/service/ImageService.java @@ -36,6 +36,8 @@ public class ImageService { @Value("${s3.bucket.name}") private String bucketName; + @Value("${s3.cloud.front.url}") + private String cloudFront; private final QuestionImageRepository questionImageRepository; @@ -125,7 +127,7 @@ private String uploadImageToS3(MultipartFile image) throws IOException { is.close(); } - return amazonS3.getUrl(bucketName, s3FileName).toString(); + return "https://" + cloudFront + "/" + s3FileName; } public void deleteImageFromS3(String imageAddress) { diff --git a/back/src/main/resources/application.properties b/back/src/main/resources/application.properties index 0e40e12825..d81e905ce4 100644 --- a/back/src/main/resources/application.properties +++ b/back/src/main/resources/application.properties @@ -25,6 +25,7 @@ s3.secret.key=${S3_SECRET_KEY} s3.bucket.name=capstone-30-backend s3.region.static=ap-northeast-2 s3.stack.auto=false +s3.cloud.front.url=${CLOUD_FRONT_URL} spring.servlet.multipart.resolve-lazily=true spring.servlet.multipart.max-file-size=100MB