Search in sources :

Example 1 with RegionEnum

use of com.mizhousoft.tencent.RegionEnum in project cloud-sdk by mizhousoft.

the class COSObjectStorageServiceImpl method init.

public void init(COSProfile config) throws CloudSDKException {
    validate(config);
    COSCredentials cred = null;
    if (StringUtils.isBlank(config.getSessionToken())) {
        cred = new BasicCOSCredentials(config.getAccessKey(), config.getSecretKey());
    } else {
        cred = new BasicSessionCredentials(config.getAccessKey(), config.getSecretKey(), config.getSessionToken());
    }
    RegionEnum region = RegionEnum.get(config.getRegion());
    ClientConfig clientConfig = new ClientConfig(new Region(region.getValue()));
    clientConfig.setHttpProtocol(HttpProtocol.https);
    COSClient cosClient = new COSClient(cred, clientConfig);
    this.profile = config;
    this.cosClient = cosClient;
    LOG.info("Init cos client successfully.");
}
Also used : COSClient(com.qcloud.cos.COSClient) COSCredentials(com.qcloud.cos.auth.COSCredentials) BasicCOSCredentials(com.qcloud.cos.auth.BasicCOSCredentials) BasicSessionCredentials(com.qcloud.cos.auth.BasicSessionCredentials) RegionEnum(com.mizhousoft.tencent.RegionEnum) BasicCOSCredentials(com.qcloud.cos.auth.BasicCOSCredentials) Region(com.qcloud.cos.region.Region) ClientConfig(com.qcloud.cos.ClientConfig)

Aggregations

RegionEnum (com.mizhousoft.tencent.RegionEnum)1 COSClient (com.qcloud.cos.COSClient)1 ClientConfig (com.qcloud.cos.ClientConfig)1 BasicCOSCredentials (com.qcloud.cos.auth.BasicCOSCredentials)1 BasicSessionCredentials (com.qcloud.cos.auth.BasicSessionCredentials)1 COSCredentials (com.qcloud.cos.auth.COSCredentials)1 Region (com.qcloud.cos.region.Region)1