|
|
@ -34,7 +34,6 @@ import java.net.URI;
|
|
|
|
import java.net.URL;
|
|
|
|
import java.net.URL;
|
|
|
|
import java.nio.file.Files;
|
|
|
|
import java.nio.file.Files;
|
|
|
|
import java.nio.file.Path;
|
|
|
|
import java.nio.file.Path;
|
|
|
|
import java.nio.file.Paths;
|
|
|
|
|
|
|
|
import java.time.Duration;
|
|
|
|
import java.time.Duration;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -84,6 +83,9 @@ public class OssClient {
|
|
|
|
StaticCredentialsProvider credentialsProvider = StaticCredentialsProvider.create(
|
|
|
|
StaticCredentialsProvider credentialsProvider = StaticCredentialsProvider.create(
|
|
|
|
AwsBasicCredentials.create(properties.getAccessKey(), properties.getSecretKey()));
|
|
|
|
AwsBasicCredentials.create(properties.getAccessKey(), properties.getSecretKey()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//MinIO 使用 HTTPS 限制使用域名访问,站点填域名。需要启用路径样式访问
|
|
|
|
|
|
|
|
boolean isStyle = !StringUtils.containsAny(properties.getEndpoint(), OssConstant.CLOUD_SERVICE);
|
|
|
|
|
|
|
|
|
|
|
|
//创建AWS基于 CRT 的 S3 客户端
|
|
|
|
//创建AWS基于 CRT 的 S3 客户端
|
|
|
|
this.client = S3AsyncClient.crtBuilder()
|
|
|
|
this.client = S3AsyncClient.crtBuilder()
|
|
|
|
.credentialsProvider(credentialsProvider)
|
|
|
|
.credentialsProvider(credentialsProvider)
|
|
|
@ -92,15 +94,15 @@ public class OssClient {
|
|
|
|
.targetThroughputInGbps(20.0)
|
|
|
|
.targetThroughputInGbps(20.0)
|
|
|
|
.minimumPartSizeInBytes(10 * 1025 * 1024L)
|
|
|
|
.minimumPartSizeInBytes(10 * 1025 * 1024L)
|
|
|
|
.checksumValidationEnabled(false)
|
|
|
|
.checksumValidationEnabled(false)
|
|
|
|
|
|
|
|
.forcePathStyle(isStyle)
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
//AWS基于 CRT 的 S3 AsyncClient 实例用作 S3 传输管理器的底层客户端
|
|
|
|
//AWS基于 CRT 的 S3 AsyncClient 实例用作 S3 传输管理器的底层客户端
|
|
|
|
this.transferManager = S3TransferManager.builder().s3Client(this.client).build();
|
|
|
|
this.transferManager = S3TransferManager.builder().s3Client(this.client).build();
|
|
|
|
|
|
|
|
|
|
|
|
// 检查是否连接到 MinIO,MinIO 使用 HTTPS 限制使用域名访问,需要启用路径样式访问
|
|
|
|
// 创建 S3 配置对象
|
|
|
|
S3Configuration config = S3Configuration.builder().chunkedEncodingEnabled(false)
|
|
|
|
S3Configuration config = S3Configuration.builder().chunkedEncodingEnabled(false)
|
|
|
|
// minio 使用https限制使用域名访问 需要此配置 站点填域名
|
|
|
|
.pathStyleAccessEnabled(isStyle).build();
|
|
|
|
.pathStyleAccessEnabled(!StringUtils.containsAny(properties.getEndpoint(), OssConstant.CLOUD_SERVICE)).build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建 预签名 URL 的生成器 实例,用于生成 S3 预签名 URL
|
|
|
|
// 创建 预签名 URL 的生成器 实例,用于生成 S3 预签名 URL
|
|
|
|
this.presigner = S3Presigner.builder()
|
|
|
|
this.presigner = S3Presigner.builder()
|
|
|
|