Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class SeaweedUploader(
file: MultipartFile,
keyPrefix: String,
): String {
// 설정 누락은 업로드 전에 드러내 저장소에 주인 없는 파일을 남기지 않는다.
val publicUrlBase = publicUrlBase()
val key = "$keyPrefix/${UUID.randomUUID()}${extensionOf(file.originalFilename)}"

try {
Expand All @@ -40,7 +42,7 @@ class SeaweedUploader(
throw ExpectedException("이미지 업로드에 실패했습니다.", HttpStatus.BAD_GATEWAY)
}

return "${publicUrlBase()}/$key"
return "$publicUrlBase/$key"
}

private fun publicUrlBase(): String {
Expand Down
12 changes: 5 additions & 7 deletions src/main/resources/application.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ spring:
allowed-origins:
- http://localhost:3000
- http://localhost:3001
cloud:
cloudflare:
bucket: ${R2_BUCKET:}
endpoint: ${R2_ENDPOINT:}
access-key: ${R2_ACCESS_KEY_ID:}
secret-key: ${R2_SECRET_ACCESS_KEY:}
public-url: ${R2_PUBLIC_URL:}
data:
mongodb:
# ArticleMongoEntity.documentId의 @Indexed(unique = true)를 실제 인덱스로 만들려면 필요하다
Expand Down Expand Up @@ -114,3 +107,8 @@ sdk:
exception:
enabled: true
use-english-message: false

seaweedfs:
filer-url: ${SEAWEEDFS_FILER_URL:http://localhost:8888}
# 브라우저가 이미지를 직접 받는 외부 URL. 비어 있으면 이미지 업로드가 500으로 실패한다(#48).
public-url: ${SEAWEEDFS_PUBLIC_URL:}
Loading