Search in sources :

Example 1 with SetBucketTaggingConfigurationRequest

use of com.qcloud.cos.model.SetBucketTaggingConfigurationRequest in project cos-java-sdk-v5 by tencentyun.

the class BucketDemo method SetGetDeleteBucketTagging.

// 使用 bucket tag
public static void SetGetDeleteBucketTagging() {
    // 1 初始化用户身份信息(secretId, secretKey)
    COSCredentials cred = new BasicCOSCredentials("AKIDXXXXXXXX", "1A2Z3YYYYYYYYYY");
    // 2 设置bucket的区域, COS地域的简称请参照 https://www.qcloud.com/document/product/436/6224
    ClientConfig clientConfig = new ClientConfig(new Region("ap-guangzhou"));
    // 3 生成cos客户端
    COSClient cosclient = new COSClient(cred, clientConfig);
    // bucket名需包含appid
    String bucketName = "mybucket-1251668577";
    List<TagSet> tagSetList = new LinkedList<TagSet>();
    TagSet tagSet = new TagSet();
    tagSet.setTag("age", "18");
    tagSet.setTag("name", "xiaoming");
    tagSetList.add(tagSet);
    BucketTaggingConfiguration bucketTaggingConfiguration = new BucketTaggingConfiguration();
    bucketTaggingConfiguration.setTagSets(tagSetList);
    SetBucketTaggingConfigurationRequest setBucketTaggingConfigurationRequest = new SetBucketTaggingConfigurationRequest(bucketName, bucketTaggingConfiguration);
    cosclient.setBucketTaggingConfiguration(setBucketTaggingConfigurationRequest);
    cosclient.getBucketTaggingConfiguration(bucketName);
    cosclient.deleteBucketTaggingConfiguration(bucketName);
}
Also used : COSClient(com.qcloud.cos.COSClient) COSCredentials(com.qcloud.cos.auth.COSCredentials) BasicCOSCredentials(com.qcloud.cos.auth.BasicCOSCredentials) BucketTaggingConfiguration(com.qcloud.cos.model.BucketTaggingConfiguration) BasicCOSCredentials(com.qcloud.cos.auth.BasicCOSCredentials) TagSet(com.qcloud.cos.model.TagSet) Region(com.qcloud.cos.region.Region) SetBucketTaggingConfigurationRequest(com.qcloud.cos.model.SetBucketTaggingConfigurationRequest) ClientConfig(com.qcloud.cos.ClientConfig) LinkedList(java.util.LinkedList)

Example 2 with SetBucketTaggingConfigurationRequest

use of com.qcloud.cos.model.SetBucketTaggingConfigurationRequest in project cos-java-sdk-v5 by tencentyun.

the class BucketTaggingDemo method SetGetDeleteBucketTagging.

public static void SetGetDeleteBucketTagging() {
    // 1 初始化用户身份信息(secretId, secretKey)
    COSCredentials cred = new BasicCOSCredentials("AKIDXXXXXXXX", "1A2Z3YYYYYYYYYY");
    // 2 设置bucket的区域, COS地域的简称请参照 https://www.qcloud.com/document/product/436/6224
    ClientConfig clientConfig = new ClientConfig(new Region("ap-guangzhou"));
    // 3 生成cos客户端
    COSClient cosclient = new COSClient(cred, clientConfig);
    // bucket名需包含appid
    String bucketName = "mybucket-1251668577";
    List<TagSet> tagSetList = new LinkedList<TagSet>();
    TagSet tagSet = new TagSet();
    tagSet.setTag("age", "18");
    tagSet.setTag("name", "xiaoming");
    tagSetList.add(tagSet);
    BucketTaggingConfiguration bucketTaggingConfiguration = new BucketTaggingConfiguration();
    bucketTaggingConfiguration.setTagSets(tagSetList);
    SetBucketTaggingConfigurationRequest setBucketTaggingConfigurationRequest = new SetBucketTaggingConfigurationRequest(bucketName, bucketTaggingConfiguration);
    cosclient.setBucketTaggingConfiguration(setBucketTaggingConfigurationRequest);
    BucketTaggingConfiguration bucketTaggingConfiguration1 = cosclient.getBucketTaggingConfiguration(bucketName);
    cosclient.deleteBucketTaggingConfiguration(bucketName);
}
Also used : COSClient(com.qcloud.cos.COSClient) COSCredentials(com.qcloud.cos.auth.COSCredentials) BasicCOSCredentials(com.qcloud.cos.auth.BasicCOSCredentials) BucketTaggingConfiguration(com.qcloud.cos.model.BucketTaggingConfiguration) BasicCOSCredentials(com.qcloud.cos.auth.BasicCOSCredentials) TagSet(com.qcloud.cos.model.TagSet) Region(com.qcloud.cos.region.Region) SetBucketTaggingConfigurationRequest(com.qcloud.cos.model.SetBucketTaggingConfigurationRequest) ClientConfig(com.qcloud.cos.ClientConfig) LinkedList(java.util.LinkedList)

Aggregations

COSClient (com.qcloud.cos.COSClient)2 ClientConfig (com.qcloud.cos.ClientConfig)2 BasicCOSCredentials (com.qcloud.cos.auth.BasicCOSCredentials)2 COSCredentials (com.qcloud.cos.auth.COSCredentials)2 BucketTaggingConfiguration (com.qcloud.cos.model.BucketTaggingConfiguration)2 SetBucketTaggingConfigurationRequest (com.qcloud.cos.model.SetBucketTaggingConfigurationRequest)2 TagSet (com.qcloud.cos.model.TagSet)2 Region (com.qcloud.cos.region.Region)2 LinkedList (java.util.LinkedList)2