added advertising
This commit is contained in:
@@ -10,10 +10,12 @@ import software.amazon.awssdk.services.s3.S3Client;
|
||||
import software.amazon.awssdk.services.s3.S3Configuration;
|
||||
|
||||
import java.net.URI;
|
||||
import software.amazon.awssdk.services.s3.presigner.S3Presigner;
|
||||
|
||||
@Configuration
|
||||
@RequiredArgsConstructor
|
||||
public class S3ClientConfig {
|
||||
|
||||
private final MinioProperties properties;
|
||||
|
||||
@Bean
|
||||
@@ -21,12 +23,29 @@ public class S3ClientConfig {
|
||||
return S3Client.builder()
|
||||
.endpointOverride(URI.create(properties.endpoint()))
|
||||
.region(Region.of(properties.region()))
|
||||
.credentialsProvider(StaticCredentialsProvider.create(
|
||||
AwsBasicCredentials.create(properties.accessKey(), properties.secretKey())))
|
||||
// ВАЖНО для MinIO: path-style вместо virtual-hosted style
|
||||
.serviceConfiguration(S3Configuration.builder()
|
||||
.pathStyleAccessEnabled(true)
|
||||
.build())
|
||||
.credentialsProvider(credentialsProvider())
|
||||
.serviceConfiguration(pathStyleConfiguration())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public S3Presigner s3Presigner() {
|
||||
return S3Presigner.builder()
|
||||
.endpointOverride(URI.create(properties.endpoint()))
|
||||
.region(Region.of(properties.region()))
|
||||
.credentialsProvider(credentialsProvider())
|
||||
.serviceConfiguration(pathStyleConfiguration())
|
||||
.build();
|
||||
}
|
||||
|
||||
private StaticCredentialsProvider credentialsProvider() {
|
||||
return StaticCredentialsProvider.create(
|
||||
AwsBasicCredentials.create(properties.accessKey(), properties.secretKey()));
|
||||
}
|
||||
|
||||
private S3Configuration pathStyleConfiguration() {
|
||||
return S3Configuration.builder()
|
||||
.pathStyleAccessEnabled(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user