-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: storage client 를 상위 패키지로 이동하여 하위 패키지들에서 사용할 수 있도록 수정
- Loading branch information
1 parent
af1503c
commit e4d79bd
Showing
7 changed files
with
72 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
storage/src/main/kotlin/com/few/storage/config/ClientConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.few.storage.config | ||
|
||
import com.amazonaws.auth.AWSStaticCredentialsProvider | ||
import com.amazonaws.auth.BasicAWSCredentials | ||
import com.amazonaws.client.builder.AwsClientBuilder | ||
import com.amazonaws.services.s3.AmazonS3Client | ||
import com.amazonaws.services.s3.AmazonS3ClientBuilder | ||
import org.springframework.beans.factory.annotation.Value | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
|
||
@Configuration | ||
class ClientConfig( | ||
@Value("\${storage.url}") val url: String, | ||
@Value("\${storage.access-key}") val accessKey: String, | ||
@Value("\${storage.secret-key}") val secretKey: String, | ||
@Value("\${storage.region}") val region: String | ||
) { | ||
|
||
@Bean | ||
fun s3StorageClient(): AmazonS3Client { | ||
val builder = AmazonS3ClientBuilder.standard() | ||
.withCredentials( | ||
AWSStaticCredentialsProvider( | ||
BasicAWSCredentials( | ||
accessKey, | ||
secretKey | ||
) | ||
) | ||
) | ||
.withEndpointConfiguration( | ||
AwsClientBuilder.EndpointConfiguration( | ||
url, | ||
region | ||
) | ||
) | ||
|
||
builder.build().let { client -> | ||
return client as AmazonS3Client | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
storage/src/main/kotlin/com/few/storage/image/config/ImageStorageConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
storage: | ||
url: http://127.0.0.1:9000 | ||
access-key: thisisroot | ||
secret-key: thisisroot | ||
region: ap-northeast-2 | ||
|
||
image: | ||
store: | ||
url: http://127.0.0.1:9000 | ||
access-key: thisisroot | ||
secret-key: thisisroot | ||
bucket-name: picture | ||
region: ap-northeast-2 | ||
|
||
cdn: | ||
url: http://127.0.0.1:9000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
storage: | ||
url: ${STORAGE_URL} | ||
access-key: ${STORAGE_ACCESS_KEY} | ||
secret-key: ${STORAGE_SECRET_KEY} | ||
region: ${STORAGE_REGION} | ||
|
||
image: | ||
store: | ||
url: ${IMAGE_STORE_URL} | ||
access-key: ${IMAGE_STORE_ACCESS_KEY} | ||
secret-key: ${IMAGE_STORE_SECRET_KEY} | ||
bucket-name: ${IMAGE_STORE_BUCKET_NAME} | ||
region: ${IMAGE_STORE_REGION} | ||
region: ${STORAGE_REGION} | ||
|
||
cdn: | ||
url: ${CDN_URL} |