Skip to content

Commit

Permalink
Merge branch 'develop/be' into feature/be/#467
Browse files Browse the repository at this point in the history
  • Loading branch information
Libienz authored Sep 26, 2024
2 parents d3fdbcc + 34421b2 commit 83341db
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ public class AwsS3Provider {
private final S3Client s3Client;
private final String bucket;
private final String imageBaseUri;
private final String tourootStoragePath;
private final String originStoragePath;
private final String temporaryStoragePath;
private final String imageStoragePath;

public AwsS3Provider(
S3Client s3Client,
@Value("${cloud.aws.s3.bucket}") String bucket,
@Value("${cloud.aws.s3.image-base-uri}") String imageBaseUri,
@Value("${cloud.aws.s3.base-storage-path}") String tourootStoragePath,
@Value("${cloud.aws.s3.origin-storage-path}") String originStoragePath,
@Value("${cloud.aws.s3.temporary-storage-path}") String temporaryStoragePath,
@Value("${cloud.aws.s3.image-storage-path}") String imageStoragePath
) {
this.s3Client = s3Client;
this.bucket = bucket;
this.imageBaseUri = imageBaseUri;
this.tourootStoragePath = tourootStoragePath;
this.originStoragePath = originStoragePath;
this.temporaryStoragePath = temporaryStoragePath;
this.imageStoragePath = imageStoragePath;
}
Expand All @@ -48,7 +48,7 @@ public List<String> uploadImages(List<ImageFile> files) {
.map(ImageFile::getFile)
.forEach(file -> {
String newFileName = createNewFileName(file.getOriginalFilename());
String filePath = tourootStoragePath + temporaryStoragePath + newFileName;
String filePath = originStoragePath + temporaryStoragePath + newFileName;
uploadFile(file, filePath, s3Client);
String s3Key = imageBaseUri + temporaryStoragePath + newFileName;
urls.add(s3Key);
Expand Down Expand Up @@ -83,7 +83,7 @@ public String copyImageToPermanentStorage(String imageUrl) {

validateS3Path(imageUrl);
String fileName = imageUrl.substring(imageUrl.lastIndexOf("/") + 1);
String sourceKey = tourootStoragePath + temporaryStoragePath + fileName;
String sourceKey = originStoragePath + temporaryStoragePath + fileName;
String destinationKey = sourceKey.replace(temporaryStoragePath, imageStoragePath);
copyFile(sourceKey, destinationKey);
return imageUrl.replace(temporaryStoragePath, imageStoragePath);
Expand Down
4 changes: 3 additions & 1 deletion backend/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ cloud:
s3:
bucket: techcourse-project-2024
image-base-uri: https://dev.touroot.kr/
base-storage-path: touroot/
temporary-storage-path: temporary/
image-storage-path: images/

Expand Down Expand Up @@ -72,6 +71,7 @@ cloud:
aws:
s3:
image-base-uri: https://dev.touroot.kr/
origin-storage-path: touroot/
---
# dev profile
spring:
Expand Down Expand Up @@ -124,6 +124,7 @@ cloud:
aws:
s3:
image-base-uri: https://dev.touroot.kr/
origin-storage-path: touroot-dev/
---
# prod profile
spring:
Expand Down Expand Up @@ -186,3 +187,4 @@ cloud:
aws:
s3:
image-base-uri: https://touroot.kr/
origin-storage-path: touroot/
2 changes: 1 addition & 1 deletion backend/src/test/resources/application-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cloud:
s3:
bucket: techcourse-project-2024
image-base-uri: https://dev.touroot.kr/
base-storage-path: touroot/
origin-storage-path: touroot/
temporary-storage-path: temporary/
image-storage-path: images/
server:
Expand Down

0 comments on commit 83341db

Please sign in to comment.