Skip to content

Commit

Permalink
fix: adapt cdn image url
Browse files Browse the repository at this point in the history
  • Loading branch information
DongGeon0908 committed Aug 6, 2024
1 parent 4a05d2a commit 4a39e09
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()}"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class ImageMetadata(
@Column(name = "filename")
val filename: String,

/** cdn image url을 저장 */
@Column(name = "image_url")
val imageUrl: String,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<FilePart>,
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 4a39e09

Please sign in to comment.