Skip to content

Commit

Permalink
Api-Release-v0.0.2-24
Browse files Browse the repository at this point in the history
Api-Release-v0.0.2-24
  • Loading branch information
imenuuu authored Dec 21, 2023
2 parents 7f17fa8 + c615396 commit 972a432
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public static class BannerUpload {
public static class BannerPatchDto {
private String name;

private String contentsUrl;

private LocalDateTime startDate;

private LocalDateTime endDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public class MatchStatic {
public static final String FIRST_TIME = "T00:00:00";
public static final String LAST_TIME = "T23:59:59";

public static final String BASE_PROFILE = "https://match-image.s3.ap-northeast-2.amazonaws.com/profile.png";
public static final String BASE_PROFILE = "https://d331gpen6ndprr.cloudfront.net/profile.png";

public static final String MATCH_PROFILE = "https://match-image.s3.ap-northeast-2.amazonaws.com/profile.png";
public static final String MATCH_PROFILE = "https://d331gpen6ndprr.cloudfront.net/profile.png";

public static final String MATCH_NAME = "매치";

Expand Down
4 changes: 2 additions & 2 deletions Match-Common/src/main/resources/templates/TemplateMail.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<table style="max-width: 630px; margin: 0 auto; letter-spacing: -1px; font-family: 나눔고딕,serif;">
<tr>
<td style="border: 10px solid #f2f2f2; padding: 90px 14px; text-align: center;">
<img src="https://match-image.s3.ap-northeast-2.amazonaws.com/match.png" width="690" alt="MATCH Logo" />
<img src="https://d331gpen6ndprr.cloudfront.net/match.png" width="690" alt="MATCH Logo" />
<h1 style="font-size: 50px; line-height: 48px; font-weight: bold; color: #000000; padding-bottom: 60px; text-align: left;">
이메일 인증번호 안내
</h1>
Expand All @@ -33,7 +33,7 @@ <h1 style="font-size: 50px; line-height: 48px; font-weight: bold; color: #000000
감사합니다.
</p>
<div style="text-align: center;">
<img src="https://match-image.s3.ap-northeast-2.amazonaws.com/cat.png" width="400" alt="Cute Cat" style="display: block; margin: 0 auto;" />
<img src="https://d331gpen6ndprr.cloudfront.net/cat.png" width="400" alt="Cute Cat" style="display: block; margin: 0 auto;" />
</div>
</td>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@Getter
@AllArgsConstructor
public enum FlameImage {
NORMAL_IMG("https://match-image.s3.ap-northeast-2.amazonaws.com/flame.png"),
TUTORIAL_IMG("https://match-image.s3.ap-northeast-2.amazonaws.com/tutorial_flame.png");
NORMAL_IMG("https://d331gpen6ndprr.cloudfront.net/flame.png"),
TUTORIAL_IMG("https://d331gpen6ndprr.cloudfront.net/tutorial_flame.png");
private final String img;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
@RequiredArgsConstructor
@Slf4j
public class S3UploadService {
private static final String CLOUD_FRONT_DOMAIN_NAME = "https://d331gpen6ndprr.cloudfront.net";

private final AmazonS3 amazonS3;
private final AwsS3Properties awsS3Properties;
Expand Down Expand Up @@ -99,7 +100,7 @@ public List<String> listUploadCompleteFiles(Long historyId,List<MultipartFile> m

try (InputStream inputStream = file.getInputStream()) {
amazonS3.putObject(new PutObjectRequest(awsS3Properties.getS3().getBucket(), fileName, inputStream, objectMetadata).withCannedAcl(CannedAccessControlList.PublicRead));
imgUrlList.add(amazonS3.getUrl(awsS3Properties.getS3().getBucket(), fileName).toString());
imgUrlList.add(getImageUrl(fileName));
} catch (IOException e) {
log.info("파일 업로드 실패 프로젝트 ID : " + historyId);
throw new ForbiddenException(IMAGE_UPLOAD_ERROR);
Expand Down Expand Up @@ -136,12 +137,12 @@ public String uploadProjectPresentFile(Long projectId,MultipartFile presentFile)
log.info("파일 업로드 실패 프로젝트 ID : " + projectId);
throw new ForbiddenException(IMAGE_UPLOAD_ERROR);
}
return amazonS3.getUrl(awsS3Properties.getS3().getBucket(), fileName).toString();
return getImageUrl(fileName);
}

public void deleteFile(String fileName){
int index=fileName.indexOf(awsS3Properties.getS3().getBaseUrl());
String fileRoute=fileName.substring(index+awsS3Properties.getS3().getBaseUrl().length()+1);
int index=fileName.indexOf(CLOUD_FRONT_DOMAIN_NAME);
String fileRoute=fileName.substring(index+CLOUD_FRONT_DOMAIN_NAME.length()+1);
try {
boolean isObjectExist = amazonS3.doesObjectExist(awsS3Properties.getS3().getBucket(), fileRoute);
if (isObjectExist) {
Expand All @@ -165,7 +166,7 @@ public String uploadProfilePresentFile(Long userId,MultipartFile presentFile) {
log.info("파일 업로드 실패 프로젝트 ID : " + userId);
throw new ForbiddenException(IMAGE_UPLOAD_ERROR);
}
return amazonS3.getUrl(awsS3Properties.getS3().getBucket(), fileName).toString();
return getImageUrl(fileName);
}

public String uploadBannerImage(MultipartFile bannerImage) {
Expand All @@ -179,7 +180,7 @@ public String uploadBannerImage(MultipartFile bannerImage) {
} catch (IOException e) {
throw new ForbiddenException(IMAGE_UPLOAD_ERROR);
}
return amazonS3.getUrl(awsS3Properties.getS3().getBucket(), fileName).toString();
return getImageUrl(fileName);
}

private String getForBannerFileName(String fileExtension) {
Expand All @@ -196,7 +197,7 @@ public String uploadByteCode(String s3FileName, byte[] thumbnailBytes) {

amazonS3.putObject(new PutObjectRequest(awsS3Properties.getS3().getBucket(),s3FileName,new ByteArrayInputStream(thumbnailBytes),metadata));

return amazonS3.getUrl(awsS3Properties.getS3().getBucket(),s3FileName).toString();
return getImageUrl(s3FileName);
}


Expand All @@ -218,12 +219,16 @@ public String uploadOneImg(String dirName, MultipartFile imgFile) {
} catch (IOException e) {
throw new ForbiddenException(IMAGE_UPLOAD_ERROR);
}
return amazonS3.getUrl(awsS3Properties.getS3().getBucket(), fileName).toString();
return getImageUrl(fileName);
}

private String getForOneFileName(String dirName, String fileExtension) {
return dirName+"/"
+ UUID.randomUUID()
+ fileExtension;
}

private String getImageUrl(String fileName){
return CLOUD_FRONT_DOMAIN_NAME + "/" + fileName;
}
}

0 comments on commit 972a432

Please sign in to comment.