Added property endpoint (#76)

This commit is contained in:
Denis Kazantsev 2022-07-14 16:02:02 +03:00 committed by GitHub
parent eeaa02e7ea
commit 1c5ef179ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import software.amazon.awssdk.auth.credentials.AwsBasicCredentials
import software.amazon.awssdk.regions.Region
import software.amazon.awssdk.services.s3.S3Client
import software.amazon.awssdk.services.s3.presigner.S3Presigner
import java.net.URI
@ComponentScan("ru.touchin.s3.storage")
@ConfigurationPropertiesScan("ru.touchin.s3.storage")
@ -20,6 +21,7 @@ class S3Configuration(private val s3Properties: S3Properties) {
return S3Client.builder()
.region(region)
.credentialsProvider { getCredentialsProvider() }
.apply { if (s3Properties.endpoint != null) endpointOverride(URI.create(s3Properties.endpoint)) }
.build()
}
@ -28,6 +30,7 @@ class S3Configuration(private val s3Properties: S3Properties) {
return S3Presigner.builder()
.region(region)
.credentialsProvider { getCredentialsProvider() }
.apply { if (s3Properties.endpoint != null) endpointOverride(URI.create(s3Properties.endpoint)) }
.build()
}

View File

@ -11,5 +11,6 @@ data class S3Properties(
val region: String,
val bucket: String,
val folder: String,
val endpoint: String?,
)