Search in sources :

Example 1 with QcloudFileProperties

use of com.zhouzifei.tool.config.QcloudFileProperties in project simpleFS by shengdingbox.

the class QCloudOssApiClient method init.

@Override
public QCloudOssApiClient init(FileProperties fileProperties) {
    final QcloudFileProperties qcloudFileProperties = fileProperties.getTengxun();
    String accessKey = qcloudFileProperties.getAccessKey();
    String secretKey = qcloudFileProperties.getSecretKey();
    String endpoint = qcloudFileProperties.getEndpoint();
    String url = qcloudFileProperties.getUrl();
    this.bucketName = qcloudFileProperties.getBucketName();
    checkDomainUrl(url);
    if (StringUtils.isNullOrEmpty(accessKey) || StringUtils.isNullOrEmpty(secretKey) || StringUtils.isNullOrEmpty(bucketName)) {
        throw new ServiceException("[" + this.storageType + "]尚未配置腾讯云,文件上传功能暂时不可用!");
    }
    COSCredentials cred = new BasicCOSCredentials(accessKey, secretKey);
    Region region = new Region(endpoint);
    ClientConfig clientConfig = new ClientConfig(region);
    cosClient = new COSClient(cred, clientConfig);
    return this;
}
Also used : COSClient(com.qcloud.cos.COSClient) COSCredentials(com.qcloud.cos.auth.COSCredentials) BasicCOSCredentials(com.qcloud.cos.auth.BasicCOSCredentials) ServiceException(com.zhouzifei.tool.common.ServiceException) BasicCOSCredentials(com.qcloud.cos.auth.BasicCOSCredentials) Region(com.qcloud.cos.region.Region) QcloudFileProperties(com.zhouzifei.tool.config.QcloudFileProperties) ClientConfig(com.qcloud.cos.ClientConfig)

Aggregations

COSClient (com.qcloud.cos.COSClient)1 ClientConfig (com.qcloud.cos.ClientConfig)1 BasicCOSCredentials (com.qcloud.cos.auth.BasicCOSCredentials)1 COSCredentials (com.qcloud.cos.auth.COSCredentials)1 Region (com.qcloud.cos.region.Region)1 ServiceException (com.zhouzifei.tool.common.ServiceException)1 QcloudFileProperties (com.zhouzifei.tool.config.QcloudFileProperties)1