Skip to content

Commit

Permalink
URI Clound Front 도입 (#436)
Browse files Browse the repository at this point in the history
* fix : 사진 저장 uri 가 cloudfront를 사용하도록 변경

* fix : 사진 저장 uri 가 cloudfront를 사용하도록 변경된 대로 테스트 코드 수정 (#437)
  • Loading branch information
birdieHyun authored May 23, 2024
1 parent cd9ff85 commit 430ac35
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public StoreImageService(S3Client s3Client, StoreImageRepository storeImageRepos
@CacheEvict(value = "stores", key = "'allStores'")
public String uploadFile(MultipartFile file, long storeDetailId, String randomId) {

StringBuilder sb = new StringBuilder();
String fileName = file.getOriginalFilename() + randomId;
String contentType = file.getContentType();

Expand All @@ -56,14 +55,9 @@ public String uploadFile(MultipartFile file, long storeDetailId, String randomId
.contentType(contentType)
.build();

String url = sb.append("https://")
.append(bucketName)
.append(".s3.ap-northeast-2.amazonaws.com/store-image/")
.append(fileName)
.toString();

try {
s3Client.putObject(putObjectRequest, RequestBody.fromInputStream(file.getInputStream(), file.getSize()));
String url = "https://file.upbrella.co.kr/store-image/" + fileName;
saveStoreImage(url, storeDetailId);
return url;
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void uploadFileTest() {
StoreDetail storeDetail = StoreDetail.builder()
.build();
String randomId = storeImageService.makeRandomId();
String expectedUrl = "https://null.s3.ap-northeast-2.amazonaws.com/store-image/filename.jpg" + randomId;
String expectedUrl = "https://file.upbrella.co.kr/store-image/filename.jpg" + randomId;

given(storeDetailService.findByStoreMetaId(storeDetailId)).willReturn(storeDetail);
given(s3Client.putObject(any(PutObjectRequest.class), any(RequestBody.class))).willReturn(PutObjectResponse.builder().build());
Expand Down

0 comments on commit 430ac35

Please sign in to comment.