Skip to content

Commit

Permalink
Merge pull request #233 from kookmin-sw/feature/be/#232-cloud-front
Browse files Browse the repository at this point in the history
feat: #232-cloud front 캐싱 주소저장 변경
  • Loading branch information
BlueBerrySoda authored May 22, 2024
2 parents f43e14d + b0910a4 commit 78861be
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
echo REDIS_PORT=${{ secrets.REDIS_PORT }} >> .env
echo S3_ACCESS_KEY=${{ secrets.S3_ACCESS_KEY }} >> .env
echo S3_SECRET_KEY=${{ secrets.S3_SECRET_KEY }} >> .env
echo CLOUD_FRONT_URL=${{ secrets.CLOUD_FRONT_URL }} >> .env
echo SECRET_KEY_BASE=${{ secrets.SECRET_KEY_BASE }} >> .env
echo SERVER_NAME=${{ secrets.SERVER_NAME }} >> .env
echo SERVER_URL=${{ secrets.SERVER_URL }} >> .env
Expand Down
3 changes: 2 additions & 1 deletion back/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ REDIS_PORT=
## S3
S3_ACCESS_KEY=
S3_SECRET_KEY=
CLOUD_FRONT_URL=

## Ruby On Rails Production Key
SECRET_KEY_BASE=
Expand All @@ -38,4 +39,4 @@ SECRET_KEY_BASE=
SERVER_NAME=

## CHAT BOT ENV
CHATBOT_URL=
CHATBOT_URL=
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions back/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 78861be

Please sign in to comment.