Skip to content

Commit

Permalink
Merge pull request #273 from CaZaIt/refactor/s3
Browse files Browse the repository at this point in the history
[Chore] #268 - PreSignedUrl DTO 네이밍 변경
  • Loading branch information
parkrootseok authored May 10, 2023
2 parents eb624f4 + afb1ca4 commit f1950c9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/main/java/shop/cazait/domain/s3/api/S3ApiController.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import shop.cazait.domain.s3.dto.GetPreSignedUrlRes;
import shop.cazait.domain.s3.dto.response.PreSignedUrlCreateOutDTO;
import shop.cazait.domain.s3.service.S3Service;
import shop.cazait.global.common.dto.response.SuccessResponse;
import shop.cazait.global.config.encrypt.NoAuth;
Expand All @@ -26,7 +26,7 @@ public class S3ApiController {
@GetMapping("/pre-signed")
@Operation(summary = "미리 서명된 주소 생성", description = "이미지 업로드를 위해 필요한 미리 서명된 주소를 받는다.")
@Parameter(name = "directory", description = "이미지 종류", example = "cafe")
public SuccessResponse<GetPreSignedUrlRes> createPreSignedUrl(@RequestParam String directory) {
public SuccessResponse<PreSignedUrlCreateOutDTO> createPreSignedUrl(@RequestParam String directory) {
return new SuccessResponse<>(SuccessStatus.SUCCESS, s3Service.createPreSignedUrl(directory));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package shop.cazait.domain.s3.dto;
package shop.cazait.domain.s3.dto.response;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;

@Schema(description = "이미지 업로드 Response : 미리 서명된 주소를 받아 이미지 업로드")
@Schema(name = "이미지 업로드 Response", description = "미리 서명된 주소를 받아 이미지 업로드")
@Getter
@Builder(access = AccessLevel.PROTECTED)
public class GetPreSignedUrlRes {
public class PreSignedUrlCreateOutDTO {

@Schema(description = "이미지 객체 Key", example = "cafe/caab93eb-e9ed-499e-be61-15cfa1069f73")
String objectKey;
@Schema(description = "미리 서명된 URL")
String preSignedUrl;

public static GetPreSignedUrlRes of(String objectKey, String preSignedUrl) {
return GetPreSignedUrlRes.builder()
public static PreSignedUrlCreateOutDTO of(String objectKey, String preSignedUrl) {
return PreSignedUrlCreateOutDTO.builder()
.objectKey(objectKey)
.preSignedUrl(preSignedUrl)
.build();
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/shop/cazait/domain/s3/service/S3Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import shop.cazait.domain.s3.dto.GetPreSignedUrlRes;
import shop.cazait.domain.s3.dto.response.PreSignedUrlCreateOutDTO;

@Slf4j
@Service
Expand All @@ -26,7 +26,7 @@ public class S3Service {
/**
* Pre-Signed Url 생성
*/
public GetPreSignedUrlRes createPreSignedUrl(String directory) {
public PreSignedUrlCreateOutDTO createPreSignedUrl(String directory) {

String objectKey = directory + "/" + UUID.randomUUID().toString();
log.info(objectKey);
Expand All @@ -47,7 +47,7 @@ public GetPreSignedUrlRes createPreSignedUrl(String directory) {
URL preSignedUrl = amazonS3.generatePresignedUrl(generatePresignedUrlRequest);

log.info("Pre-Signed URL : " + preSignedUrl.toString());
return GetPreSignedUrlRes.of(objectKey, preSignedUrl.toString());
return PreSignedUrlCreateOutDTO.of(objectKey, preSignedUrl.toString());

}

Expand Down

0 comments on commit f1950c9

Please sign in to comment.