|
|
@ -74,9 +74,12 @@ public class FileConfig implements WebMvcConfigurer { |
|
|
@Bean |
|
|
@Bean |
|
|
@ConditionalOnProperty(prefix = "file.storage", name = {"mode"}, havingValue = MODE_CLOUD) |
|
|
@ConditionalOnProperty(prefix = "file.storage", name = {"mode"}, havingValue = MODE_CLOUD) |
|
|
public S3Client initAmazonS3() { |
|
|
public S3Client initAmazonS3() { |
|
|
|
|
|
String endpointUrl = endpoint.startsWith(HTTP) || endpoint.startsWith(HTTPS) |
|
|
|
|
|
? endpoint |
|
|
|
|
|
: HTTP + endpoint; |
|
|
return S3Client.builder() |
|
|
return S3Client.builder() |
|
|
.region(Region.AWS_GLOBAL) |
|
|
.region(Region.of(region)) |
|
|
.endpointOverride(URI.create((urlPrefix.startsWith(HTTPS) ? HTTPS : HTTP) + endpoint)) |
|
|
.endpointOverride(URI.create(endpointUrl)) |
|
|
.credentialsProvider( |
|
|
.credentialsProvider( |
|
|
StaticCredentialsProvider.create( |
|
|
StaticCredentialsProvider.create( |
|
|
AwsBasicCredentials.create(accessKey, secretKey))) |
|
|
AwsBasicCredentials.create(accessKey, secretKey))) |
|
|
|