diff --git a/src/main/kotlin/com/hero/alignlab/client/s3/client/S3Client.kt b/src/main/kotlin/com/hero/alignlab/client/s3/client/S3Client.kt index 05b5e2d..5cf0a53 100644 --- a/src/main/kotlin/com/hero/alignlab/client/s3/client/S3Client.kt +++ b/src/main/kotlin/com/hero/alignlab/client/s3/client/S3Client.kt @@ -28,7 +28,7 @@ class S3Client( runCatching { resolveRequest(filePart, dataBuffer) .run { amazonS3.putObject(this) } - imageUrl(filePart.filename()) + cdnImageUrl(filePart.filename()) }.fold( onSuccess = { url -> Mono.just(url) @@ -68,4 +68,8 @@ class S3Client( fun imageUrl(filename: String): String { return "${s3Properties.bucketUrl}/images/${filename.encodeURL()}" } + + fun cdnImageUrl(filename: String): String { + return "${s3Properties.cdnUrl}/images/${filename.encodeURL()}" + } } diff --git a/src/main/kotlin/com/hero/alignlab/client/s3/config/S3Properties.kt b/src/main/kotlin/com/hero/alignlab/client/s3/config/S3Properties.kt index 2a067af..c4a063c 100644 --- a/src/main/kotlin/com/hero/alignlab/client/s3/config/S3Properties.kt +++ b/src/main/kotlin/com/hero/alignlab/client/s3/config/S3Properties.kt @@ -29,5 +29,9 @@ class S3Properties { @field:NotBlank @Value("\${cloud.aws.s3.bucketUrl}") var bucketUrl: String? = null + + @field:NotBlank + @Value("\${cloud.aws.s3.cdnUrl}") + var cdnUrl: String? = null } diff --git a/src/main/kotlin/com/hero/alignlab/domain/image/domain/ImageMetadata.kt b/src/main/kotlin/com/hero/alignlab/domain/image/domain/ImageMetadata.kt index 7d632d5..339f03a 100644 --- a/src/main/kotlin/com/hero/alignlab/domain/image/domain/ImageMetadata.kt +++ b/src/main/kotlin/com/hero/alignlab/domain/image/domain/ImageMetadata.kt @@ -17,6 +17,7 @@ class ImageMetadata( @Column(name = "filename") val filename: String, + /** cdn image url을 저장 */ @Column(name = "image_url") val imageUrl: String, diff --git a/src/main/kotlin/com/hero/alignlab/domain/image/resource/ImageResource.kt b/src/main/kotlin/com/hero/alignlab/domain/image/resource/ImageResource.kt index a2de783..ab2cd78 100644 --- a/src/main/kotlin/com/hero/alignlab/domain/image/resource/ImageResource.kt +++ b/src/main/kotlin/com/hero/alignlab/domain/image/resource/ImageResource.kt @@ -32,7 +32,7 @@ class ImageResource( /** 이미지 업로드시 type을 꼭 명시해야 한다. */ @Operation(summary = "이미지 벌크 업로드") @PostMapping(path = ["/api/v1/images/bulk"], consumes = [MediaType.MULTIPART_FORM_DATA_VALUE]) - suspend fun uploadImage( + suspend fun bulkUploadImage( user: AuthUser, @RequestParam type: ImageType, @RequestPart("images") images: List, diff --git a/src/main/resources/config/application.yml b/src/main/resources/config/application.yml index 52bf6a5..9505e7d 100644 --- a/src/main/resources/config/application.yml +++ b/src/main/resources/config/application.yml @@ -87,6 +87,7 @@ cloud: s3: bucket: alignlab-public-s3 bucketUrl: https://alignlab-public-s3.s3.ap-northeast-2.amazonaws.com + cdnUrl: https://cdn.alignlab.site region: static: ap-northeast-2 stack: