API | 操作名 | 操作描述 |
设置存储桶标签 | 为已存在的存储桶设置标签 | |
查询存储桶标签 | 查询指定存储桶下已有的存储桶标签 | |
删除存储桶标签 | 删除指定的存储桶标签 |
QCloudPutBucketTaggingRequest *putReq = [QCloudPutBucketTaggingRequest new];// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketputReq.bucket = @"examplebucket-1250000000";// 标签集合QCloudTagging *taggings = [QCloudTagging new];QCloudTag *tag1 = [QCloudTag new];// 标签的 Key,长度不超过128字节, 支持英文字母、数字、空格、加号、减号、下划线、等号、点号、// 冒号、斜线tag1.key = @"age";// 标签的 Value,长度不超过256字节, 支持英文字母、数字、空格、加号、减号、下划线、等号、点号// 、冒号、斜线tag1.value = @"20";QCloudTag *tag2 = [QCloudTag new];tag2.key = @"name";tag2.value = @"karis";// 标签集合,最多支持10个标签QCloudTagSet *tagSet = [QCloudTagSet new];tagSet.tag = @[tag1,tag2];taggings.tagSet = tagSet;// 标签集合putReq.taggings = taggings;[putReq setFinishBlock:^(id outputObject, NSError *error) {// outputObject 包含所有的响应 http 头部NSDictionary* info = (NSDictionary *) outputObject;}];[[QCloudCOSXMLService defaultCOSXML] PutBucketTagging:putReq];
let req = QCloudPutBucketTaggingRequest.init();// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketreq.bucket = "examplebucket-1250000000";let taggings = QCloudTagging.init();// 标签集合let tagSet = QCloudTagSet.init();taggings.tagSet = tagSet;let tag1 = QCloudTag.init();// 标签的 Key,长度不超过128字节, 支持英文字母、数字、空格、加号、减号、下划线、等号、点号、// 冒号、斜线tag1.key = "age";// 标签的 Value,长度不超过256字节, 支持英文字母、数字、空格、加号、减号、下划线、等号、点号// 、冒号、斜线tag1.value = "20";let tag2 = QCloudTag.init();tag2.key = "name";tag2.value = "karis";// 标签集合,最多支持10个标签tagSet.tag = [tag1,tag2];// 标签集合req.taggings = taggings;req.finishBlock = {(result,error) inif let result = result {// result 包含响应的 header 信息} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().putBucketTagging(req);
QCloudGetBucketTaggingRequest *getReq = [QCloudGetBucketTaggingRequest new];// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketgetReq.bucket = @"examplebucket-1250000000";[getReq setFinishBlock:^(QCloudBucketTagging * result, NSError * error) {// tag的集合QCloudTagSet * tagSet = result.tagSet;}];[[QCloudCOSXMLService defaultCOSXML] GetBucketTagging:getReq];
let req = QCloudGetBucketTaggingRequest.init();// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketreq.bucket = "examplebucket-1250000000";req.setFinish { (result, error) inif let result = result {// 标签集合let tagSet = result.tagSet} else {print(error!);}};QCloudCOSXMLService.defaultCOSXML().getBucketTagging(req);
QCloudDeleteBucketTaggingRequest *delReq = [QCloudDeleteBucketTaggingRequest new];// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketdelReq.bucket = @"examplebucket-1250000000";[delReq setFinishBlock:^(id outputObject, NSError *error) {// outputObject 包含所有的响应 http 头部NSDictionary* info = (NSDictionary *) outputObject;}];[[QCloudCOSXMLService defaultCOSXML] DeleteBucketTagging:delReq];
let req = QCloudDeleteBucketTaggingRequest.init();// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketreq.bucket = "examplebucket-1250000000";req.finishBlock = { (result, error) inif let result = result {// result 包含响应的 header 信息} else {print(error!);}};QCloudCOSXMLService.defaultCOSXML().deleteBucketTagging(req);
本页内容是否解决了您的问题?