tencent cloud

Cloud Object Storage

문서Cloud Object Storage

Tag Operation

포커스 모드
폰트 크기
마지막 업데이트 시간: 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
}


도움말 및 지원

문제 해결에 도움이 되었나요?

피드백