tencent cloud

Cloud Object Storage

Tag Operation

PDF
Modo Foco
Tamanho da Fonte
Última atualização: 2026-02-02 11:21:27

Introduction

This document provides an API overview and SDK sample code for bucket tag operations.
API
Operation Name
Operation Description
Setting Tags
Set tags for an existing bucket.
Querying Tags
Query existing tags for the specified bucket.
Deleting a tag
Deleting existing bucket tags for the specified bucket.

Setting Tags

Feature Overview

Set tags for an existing bucket (PUT Bucket tagging).

Example Code

// Bucket name, which consists of bucketname-appid (appid must be included), can be viewed in the COS console. https://console.tencentcloud.com/cos5/bucket
let bucket = "examplebucket-1250000000";

let tagSet = new List<TagObject>();
tagSet.add(new TagObject("tag1", "value1"))
tagSet.add(new TagObject("tag2", "value2"))
let request = new PutBucketTagRequest(bucket,tagSet);
try {
let result = await CosXmlBaseService.default().putBucketTag(request)
// result includes http headers, etc.
} catch (e) {
// Exception handling
}

Querying Tags

Feature Overview

Querying existing bucket tags for the specified bucket (GET Bucket tagging).

Example Code

// Bucket name, which consists of bucketname-appid (appid must be included), can be viewed in the COS console. https://console.tencentcloud.com/cos5/bucket
let bucket = "examplebucket-1250000000";

let request = new GetBucketTagRequest(bucket);
try {
let result = await CosXmlBaseService.default().getBucketTag(request)
// result includes http headers, etc.
} catch (e) {
// Exception handling
}

Deleting a Tag

Feature Overview

Deleting existing bucket tags for the specified bucket (DELETE Bucket tagging).

Example Code

// Bucket name, which consists of bucketname-appid (appid must be included), can be viewed in the COS console. https://console.tencentcloud.com/cos5/bucket
let bucket = "examplebucket-1250000000";

let request = new DeleteBucketTagRequest(bucket);
try {
let result = await CosXmlBaseService.default().deleteBucketTag(request)
// result includes http headers, etc.
} catch (e) {
// Exception handling
}


Ajuda e Suporte

Esta página foi útil?

comentários