update 增加OSS模块service自动激活

This commit is contained in:
疯狂的狮子li
2021-07-18 19:29:33 +08:00
parent f847f67982
commit 7cffafcdaa
6 changed files with 68 additions and 33 deletions

View File

@@ -32,11 +32,15 @@ public class AliyunCloudStorageServiceImpl extends AbstractCloudStorageService i
@Autowired
public AliyunCloudStorageServiceImpl(CloudStorageProperties properties) {
this.properties = properties.getAliyun();
ClientConfiguration configuration = new ClientConfiguration();
DefaultCredentialProvider credentialProvider = new DefaultCredentialProvider(
this.properties.getAccessKeyId(),
this.properties.getAccessKeySecret());
client = new OSSClient(this.properties.getEndpoint(), credentialProvider, configuration);
try {
ClientConfiguration configuration = new ClientConfiguration();
DefaultCredentialProvider credentialProvider = new DefaultCredentialProvider(
this.properties.getAccessKeyId(),
this.properties.getAccessKeySecret());
client = new OSSClient(this.properties.getEndpoint(), credentialProvider, configuration);
} catch (Exception e) {
throw new IllegalArgumentException("阿里云存储配置错误! 请检查系统配置!");
}
}
@Override

View File

@@ -29,10 +29,14 @@ public class MinioCloudStorageServiceImpl extends AbstractCloudStorageService im
@Autowired
public MinioCloudStorageServiceImpl(CloudStorageProperties properties) {
this.properties = properties.getMinio();
minioClient = MinioClient.builder()
.endpoint(this.properties.getEndpoint())
.credentials(this.properties.getAccessKey(), this.properties.getSecretKey())
.build();
try {
minioClient = MinioClient.builder()
.endpoint(this.properties.getEndpoint())
.credentials(this.properties.getAccessKey(), this.properties.getSecretKey())
.build();
} catch (Exception e) {
throw new IllegalArgumentException("Minio存储配置错误! 请检查系统配置!");
}
}
@Override

View File

@@ -32,14 +32,18 @@ public class QcloudCloudStorageServiceImpl extends AbstractCloudStorageService i
@Autowired
public QcloudCloudStorageServiceImpl(CloudStorageProperties properties) {
this.properties = properties.getQcloud();
COSCredentials credentials = new BasicCOSCredentials(
this.properties.getSecretId(),
this.properties.getSecretKey());
// 初始化客户端配置
ClientConfig clientConfig = new ClientConfig();
// 设置bucket所在的区域华南gz 华北tj 华东sh
clientConfig.setRegion(new Region(this.properties.getRegion()));
client = new COSClient(credentials, clientConfig);
try {
COSCredentials credentials = new BasicCOSCredentials(
this.properties.getSecretId(),
this.properties.getSecretKey());
// 初始化客户端配置
ClientConfig clientConfig = new ClientConfig();
// 设置bucket所在的区域华南gz 华北tj 华东sh
clientConfig.setRegion(new Region(this.properties.getRegion()));
client = new COSClient(credentials, clientConfig);
} catch (Exception e) {
throw new IllegalArgumentException("腾讯云存储配置错误! 请检查系统配置!");
}
}
@Override

View File

@@ -36,16 +36,20 @@ public class QiniuCloudStorageServiceImpl extends AbstractCloudStorageService im
@Autowired
public QiniuCloudStorageServiceImpl(CloudStorageProperties properties) {
this.properties = properties.getQiniu();
// z0 z1 z2
Configuration config = new Configuration(Region.autoRegion());
// 默认不使用https
config.useHttpsDomains = false;
uploadManager = new UploadManager(config);
Auth auth = Auth.create(
this.properties.getAccessKey(),
this.properties.getSecretKey());
token = auth.uploadToken(this.properties.getBucketName());
bucketManager = new BucketManager(auth, config);
try {
// z0 z1 z2
Configuration config = new Configuration(Region.autoRegion());
// 默认不使用https
config.useHttpsDomains = false;
uploadManager = new UploadManager(config);
Auth auth = Auth.create(
this.properties.getAccessKey(),
this.properties.getSecretKey());
token = auth.uploadToken(this.properties.getBucketName());
bucketManager = new BucketManager(auth, config);
} catch (Exception e) {
throw new IllegalArgumentException("七牛云存储配置错误! 请检查系统配置!");
}
}