mirror of
https://github.com/zfile-dev/zfile.git
synced 2025-04-19 05:34:52 +00:00
✨ minio 和 s3 存储引擎支持自定义 region 功能
This commit is contained in:
@@ -39,6 +39,8 @@ public class MinIOServiceImpl extends AbstractS3BaseFileService implements BaseF
|
||||
String accessKey = stringStorageConfigMap.get(StorageConfigConstant.ACCESS_KEY).getValue();
|
||||
String secretKey = stringStorageConfigMap.get(StorageConfigConstant.SECRET_KEY).getValue();
|
||||
String endPoint = stringStorageConfigMap.get(StorageConfigConstant.ENDPOINT_KEY).getValue();
|
||||
String region = stringStorageConfigMap.get(StorageConfigConstant.REGION_KEY).getValue();
|
||||
|
||||
bucketName = stringStorageConfigMap.get(StorageConfigConstant.BUCKET_NAME_KEY).getValue();
|
||||
basePath = stringStorageConfigMap.get(StorageConfigConstant.BASE_PATH).getValue();
|
||||
isPrivate = Convert.toBool(stringStorageConfigMap.get(StorageConfigConstant.IS_PRIVATE).getValue(), true);
|
||||
@@ -51,7 +53,7 @@ public class MinIOServiceImpl extends AbstractS3BaseFileService implements BaseF
|
||||
s3Client = AmazonS3ClientBuilder.standard()
|
||||
.withPathStyleAccessEnabled(true)
|
||||
.withCredentials(new AWSStaticCredentialsProvider(credentials))
|
||||
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endPoint, "minio")).build();
|
||||
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endPoint, region)).build();
|
||||
|
||||
testConnection();
|
||||
isInitialized = true;
|
||||
@@ -72,6 +74,7 @@ public class MinIOServiceImpl extends AbstractS3BaseFileService implements BaseF
|
||||
add(new StorageConfig("secretKey", "SecretKey"));
|
||||
add(new StorageConfig("endPoint", "服务地址"));
|
||||
add(new StorageConfig("bucketName", "存储空间名称"));
|
||||
add(new StorageConfig("region", "地域"));
|
||||
add(new StorageConfig("basePath", "基路径"));
|
||||
add(new StorageConfig("isPrivate", "是否是私有空间"));
|
||||
}};
|
||||
|
||||
@@ -40,6 +40,7 @@ public class S3ServiceImpl extends AbstractS3BaseFileService implements BaseFile
|
||||
String accessKey = stringStorageConfigMap.get(StorageConfigConstant.ACCESS_KEY).getValue();
|
||||
String secretKey = stringStorageConfigMap.get(StorageConfigConstant.SECRET_KEY).getValue();
|
||||
String endPoint = stringStorageConfigMap.get(StorageConfigConstant.ENDPOINT_KEY).getValue();
|
||||
String region = stringStorageConfigMap.get(StorageConfigConstant.REGION_KEY).getValue();
|
||||
|
||||
super.domain = stringStorageConfigMap.get(StorageConfigConstant.DOMAIN_KEY).getValue();
|
||||
super.basePath = stringStorageConfigMap.get(StorageConfigConstant.BASE_PATH).getValue();
|
||||
@@ -54,8 +55,7 @@ public class S3ServiceImpl extends AbstractS3BaseFileService implements BaseFile
|
||||
log.debug("初始化存储策略 [{}] 失败: 参数不完整", getStorageTypeEnum().getDescription());
|
||||
isInitialized = false;
|
||||
} else {
|
||||
String region = "";
|
||||
if (StringUtils.isNotNullOrEmpty(endPoint)) {
|
||||
if (StrUtil.isNotEmpty(endPoint) && StrUtil.isEmpty(region)) {
|
||||
region = endPoint.split("\\.")[1];
|
||||
}
|
||||
BasicAWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
|
||||
@@ -81,6 +81,7 @@ public class S3ServiceImpl extends AbstractS3BaseFileService implements BaseFile
|
||||
add(new StorageConfig("secretKey", "SecretKey"));
|
||||
add(new StorageConfig("endPoint", "服务地址(EndPoint)"));
|
||||
add(new StorageConfig("bucketName", "存储空间名称"));
|
||||
add(new StorageConfig("region", "地域"));
|
||||
add(new StorageConfig("basePath", "基路径"));
|
||||
add(new StorageConfig("domain", "加速域名"));
|
||||
add(new StorageConfig("pathStyle", "域名风格"));
|
||||
|
||||
Reference in New Issue
Block a user