use of com.qcloud.cos.COSClient in project xian by happyyangyuan.
the class AbsFileOperate method getCosClient.
public COSClient getCosClient() {
if (cosClient == null) {
cosClient = new COSClient(10053621, "AKID5iJcsYewRYIJhqQsoaLQ7Ks1XIO6eYPs", "Gm0nqHOPzUG1MRRJnBLX4UwwQMoh8v4y");
ClientConfig config = new ClientConfig();
config.setRegion("sh");
cosClient.setConfig(config);
}
return cosClient;
}
use of com.qcloud.cos.COSClient in project platform by elveahuang.
the class CosStorageServiceImpl method getClient.
/**
* @see StorageService#getClient()
*/
@Override
public COSClient getClient() {
COSCredentials credentials = new BasicCOSCredentials(this.config.getAccessKey(), this.config.getSecretKey());
Region region = new Region(this.config.getEndpoint());
ClientConfig clientConfig = new ClientConfig(region);
return new COSClient(credentials, clientConfig);
}
use of com.qcloud.cos.COSClient in project litemall by linlinjava.
the class TencentStorage method getCOSClient.
private COSClient getCOSClient() {
if (cosClient == null) {
// 1 初始化用户身份信息(secretId, secretKey)
COSCredentials cred = new BasicCOSCredentials(secretId, secretKey);
// 2 设置bucket的区域, COS地域的简称请参照 https://cloud.tencent.com/document/product/436/6224
ClientConfig clientConfig = new ClientConfig(new Region(region));
cosClient = new COSClient(cred, clientConfig);
}
return cosClient;
}
use of com.qcloud.cos.COSClient in project halo by ruibaby.
the class TencentCosFileHandler method delete.
@Override
public void delete(String key) {
Assert.notNull(key, "File key must not be blank");
// Get config
String region = optionService.getByPropertyOfNonNull(TencentCosProperties.COS_REGION).toString();
String secretId = optionService.getByPropertyOfNonNull(TencentCosProperties.COS_SECRET_ID).toString();
String secretKey = optionService.getByPropertyOfNonNull(TencentCosProperties.COS_SECRET_KEY).toString();
String bucketName = optionService.getByPropertyOfNonNull(TencentCosProperties.COS_BUCKET_NAME).toString();
COSCredentials cred = new BasicCOSCredentials(secretId, secretKey);
Region regionConfig = new Region(region);
ClientConfig clientConfig = new ClientConfig(regionConfig);
// Init OSS client
COSClient cosClient = new COSClient(cred, clientConfig);
try {
cosClient.deleteObject(bucketName, key);
} catch (Exception e) {
throw new FileOperationException("附件 " + key + " 从腾讯云删除失败", e);
} finally {
cosClient.shutdown();
}
}
use of com.qcloud.cos.COSClient in project yili-music by programmer-yili.
the class CosStorageServiceImpl method getFileUri.
@Override
public String getFileUri(String fileKey) {
COSClient cosClient = createCOSClient();
Date expirationDate = new Date(System.currentTimeMillis() + 30 * 60 * 1000);
Map<String, String> params = new HashMap<String, String>();
Map<String, String> headers = new HashMap<String, String>();
HttpMethodName method = HttpMethodName.GET;
URL url = cosClient.generatePresignedUrl(bucket, fileKey, expirationDate, method, headers, params);
cosClient.shutdown();
return url.toString();
}
Aggregations