From 3386a287584be119a12821adcbd81634137f7507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9A=A9=EC=88=98?= Date: Wed, 2 Oct 2024 11:48:07 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20ImageMetaData=20=EC=9A=94=EC=B2=AD=20?= =?UTF-8?q?=EB=B0=8F=20API=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../image/controller/ImageController.java | 14 ++++++++++++ .../image/entity/dto/ImageMetaRequest.java | 22 +++++++++++++++++++ .../entity/dto/ImagePresignedUrlResponse.java | 22 +++++++++++++++++++ .../domain/image/service/ImageService.java | 6 ++--- 4 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 backend/src/main/java/com/worlabel/domain/image/entity/dto/ImageMetaRequest.java create mode 100644 backend/src/main/java/com/worlabel/domain/image/entity/dto/ImagePresignedUrlResponse.java diff --git a/backend/src/main/java/com/worlabel/domain/image/controller/ImageController.java b/backend/src/main/java/com/worlabel/domain/image/controller/ImageController.java index 5a8ba89..35d8f68 100644 --- a/backend/src/main/java/com/worlabel/domain/image/controller/ImageController.java +++ b/backend/src/main/java/com/worlabel/domain/image/controller/ImageController.java @@ -51,6 +51,20 @@ public class ImageController { imageService.uploadFolderWithImages(folderZip, projectId, folderId, memberId); } + @PostMapping("/folders/{folder_id}/images/presigned") + @SwaggerApiSuccess(description = "압축폴더를 성공적으로 업로드합니다.") + @Operation(summary = "압축 폴더 업로드", description = "압축 폴더 내 폴더와 이미지 파일을 업로드합니다.") + @SwaggerApiError({ErrorCode.BAD_REQUEST, ErrorCode.NOT_AUTHOR, ErrorCode.SERVER_ERROR}) + public List uploadFolderByPresignedImage( + @CurrentUser final Integer memberId, + @RequestBody final List imageMetaList, + @PathVariable("project_id") final Integer projectId, + @PathVariable("folder_id") final Integer folderId) { + log.debug("requestImageList {}", imageMetaList); + // TODO: 변경 + return imageMetaList.stream().map(o -> ImagePresignedUrlResponse.of(o.getId(), o.getFileName())).toList(); + } + @GetMapping("/folders/{folder_id}/images/{image_id}") @SwaggerApiSuccess(description = "이미지를 단일 조회합니다.") @Operation(summary = "이미지 단일 조회", description = "이미지 정보를 단일 조회합니다.") diff --git a/backend/src/main/java/com/worlabel/domain/image/entity/dto/ImageMetaRequest.java b/backend/src/main/java/com/worlabel/domain/image/entity/dto/ImageMetaRequest.java new file mode 100644 index 0000000..6ba85b8 --- /dev/null +++ b/backend/src/main/java/com/worlabel/domain/image/entity/dto/ImageMetaRequest.java @@ -0,0 +1,22 @@ +package com.worlabel.domain.image.entity.dto; + + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@Schema(name = "이미지 PreSigned DTO", description = "PreSigned Url을 얻기 위한 DTO") +@Getter +@ToString +@NoArgsConstructor +@AllArgsConstructor +public class ImageMetaRequest { + + @Schema(description = "이미지 Order", example = "각 이미지에 대한 Order값") + private Integer id; + + @Schema(description = "파일 이름", example = "해당 파일의 이름") + private String fileName; +} diff --git a/backend/src/main/java/com/worlabel/domain/image/entity/dto/ImagePresignedUrlResponse.java b/backend/src/main/java/com/worlabel/domain/image/entity/dto/ImagePresignedUrlResponse.java new file mode 100644 index 0000000..5dc1643 --- /dev/null +++ b/backend/src/main/java/com/worlabel/domain/image/entity/dto/ImagePresignedUrlResponse.java @@ -0,0 +1,22 @@ +package com.worlabel.domain.image.entity.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +@Schema(name = "이미지 PreSigned DTO", description = "PreSigned Url을 얻기 위한 DTO") +@Getter +@ToString +@NoArgsConstructor +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class ImagePresignedUrlResponse { + + @Schema(description = "이미지 Order", example = "각 이미지에 대한 Order값") + private Integer id; + + @Schema(description = "이미지에 대한 presignedUrl", example = "presignedUrl") + private String presignedUrl; + + public static ImagePresignedUrlResponse of(final Integer id,final String presignedUrl) { + return new ImagePresignedUrlResponse(id, presignedUrl); + } +} diff --git a/backend/src/main/java/com/worlabel/domain/image/service/ImageService.java b/backend/src/main/java/com/worlabel/domain/image/service/ImageService.java index 20b2b83..6b3e212 100644 --- a/backend/src/main/java/com/worlabel/domain/image/service/ImageService.java +++ b/backend/src/main/java/com/worlabel/domain/image/service/ImageService.java @@ -68,11 +68,11 @@ public class ImageService { int batchSize; if (totalImages <= 100) { - batchSize = 25; // 작은 이미지 수는 작은 배치 크기 + batchSize = 10; // 작은 이미지 수는 작은 배치 크기 } else if (totalImages <= 3000) { - batchSize = 50; // 중간 이미지 수는 중간 배치 크기 + batchSize = 25; // 중간 이미지 수는 중간 배치 크기 } else { - batchSize = 100; // 큰 이미지 수는 큰 배치 크기 + batchSize = 50; // 큰 이미지 수는 큰 배치 크기 } List> futures = new ArrayList<>();