API | 操作名 | 操作描述 |
设置对象标签 | 为已上传的对象设置标签 | |
查询对象标签 | 查询指定对象下已有的对象标签 | |
删除对象标签 | 删除指定对象下已有的对象标签 |
QCloudPutObjectTaggingRequest *putReq = [QCloudPutObjectTaggingRequest 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] PutObjectTagging:putReq];
let putReq = QCloudPutObjectTaggingRequest()// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketputReq.bucket = "examplebucket-1250000000";// 标签集合let taggings = QCloudTagging();let tag1 = QCloudTag();// 标签的 Key,长度不超过128字节, 支持英文字母、数字、空格、加号、减号、下划线、等号、点号、// 冒号、斜线tag1.key = "age";// 标签的 Value,长度不超过256字节, 支持英文字母、数字、空格、加号、减号、下划线、等号、点号// 、冒号、斜线tag1.value = "20";let tag2 = QCloudTag();tag2.key = "name";tag2.value = "karis";// 标签集合,最多支持10个标签let tagSet = QCloudTagSet();tagSet.tag = [tag1,tag2];taggings.tagSet = tagSet;// 标签集合putReq.taggings = taggings;req.finishBlock = {(result,error) inif let result = result {// result 包含响应的 header 信息} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().putObjectTagging(putReq);
QCloudGetObjectTaggingRequest *getReq = [QCloudGetObjectTaggingRequest new];// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketgetReq.bucket = @"examplebucket-1250000000";[getReq setFinishBlock:^(QCloudTagging * result, NSError * error) {// tag的集合QCloudTagSet * tagSet = result.tagSet;}];[[QCloudCOSXMLService defaultCOSXML] GetObjectTagging:getReq];
let getReq = QCloudGetObjectTaggingRequest();// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketgetReq.bucket = "examplebucket-1250000000";req.finishBlock = {(result,error) inif let result = result {// tag的集合let tagSet = result.tagSet;} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().getObjectTagging(getReq);
QCloudDeleteObjectTaggingRequest *request = [QCloudDeleteObjectTaggingRequest new];// 文件名request.object = @"test.png";// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketrequest.bucket = @"examplebucket-1250000000";request.versionId = @"versionId";[request setFinishBlock:^(id * result, NSError * error) {if(!error){// 删除成功}else{// 删除失败}}];[[QCloudCOSXMLService defaultCOSXML] DeleteObjectTagging:request];
let request = QCloudDeleteObjectTaggingRequest();// 文件名request.object = "test.png";// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketrequest.bucket = "examplebucket-1250000000";request.versionId = "versionId";req.finishBlock = {(result,error) inif(!error){// 删除成功}else{// 删除失败}}QCloudCOSXMLService.defaultCOSXML().deleteObjectTagging(request);
本页内容是否解决了您的问题?