API | Operation | Description |
Setting bucket tags | Sets tags for an existing bucket | |
Querying bucket tags | Queries the existing tags of a bucket | |
Deleting bucket tags | Deletes the tags of a bucket |
QCloudPutBucketTaggingRequest *putReq = [QCloudPutBucketTaggingRequest new];// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket.putReq.bucket = @"examplebucket-1250000000";// Set of tagsQCloudTagging *taggings = [QCloudTagging new];QCloudTag *tag1 = [QCloudTag new];// Tag key; this value can contain up to 128 bytes of letters, digits, spaces, plus signs, minus signs, underscores, equal signs, dots,// colons, and slashestag1.key = @"age";// Tag value; this value can contain up to 256 bytes of letters, digits, spaces, plus signs, minus signs, underscores, equal signs, dots,// colons, and slashestag1.value = @"20";QCloudTag *tag2 = [QCloudTag new];tag2.key = @"name";tag2.value = @"karis";// Set of tags. Up to 10 tags are supportedQCloudTagSet *tagSet = [QCloudTagSet new];tagSet.tag = @[tag1,tag2];taggings.tagSet = tagSet;// Set of tagsputReq.taggings = taggings;[putReq setFinishBlock:^(id outputObject, NSError *error) {// `outputObject` contains all the HTTP response headersNSDictionary* info = (NSDictionary *) outputObject;}];[[QCloudCOSXMLService defaultCOSXML] PutBucketTagging:putReq];
let req = QCloudPutBucketTaggingRequest.init();// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket.req.bucket = "examplebucket-1250000000";let taggings = QCloudTagging.init();// Set of tagslet tagSet = QCloudTagSet.init();taggings.tagSet = tagSet;let tag1 = QCloudTag.init();// Tag key; this value can contain up to 128 bytes of letters, digits, spaces, plus signs, minus signs, underscores, equal signs, dots,// colons, and slashestag1.key = "age";// Tag value; this value can contain up to 256 bytes of letters, digits, spaces, plus signs, minus signs, underscores, equal signs, dots,// colons, and slashestag1.value = "20";let tag2 = QCloudTag.init();tag2.key = "name";tag2.value = "karis";// Set of tags. Up to 10 tags are supportedtagSet.tag = [tag1,tag2];// Set of tagsreq.taggings = taggings;req.finishBlock = {(result,error) inif let result = result {// result contains response headers} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().putBucketTagging(req);
QCloudGetBucketTaggingRequest *getReq = [QCloudGetBucketTaggingRequest new];// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket.getReq.bucket = @"examplebucket-1250000000";[getReq setFinishBlock:^(QCloudBucketTagging * result, NSError * error) {// Set of tagsQCloudTagSet * tagSet = result.tagSet;}];[[QCloudCOSXMLService defaultCOSXML] GetBucketTagging:getReq];
let req = QCloudGetBucketTaggingRequest.init();// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket.req.bucket = "examplebucket-1250000000";req.setFinish { (result, error) inif let result = result {// Set of tagslet tagSet = result.tagSet} else {print(error!);}};QCloudCOSXMLService.defaultCOSXML().getBucketTagging(req);
DELETE Bucket tagging
) is used to delete the existing tags from a bucket.QCloudDeleteBucketTaggingRequest *delReq = [QCloudDeleteBucketTaggingRequest new];// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket.delReq.bucket = @"examplebucket-1250000000";[delReq setFinishBlock:^(id outputObject, NSError *error) {// outputObject contains all the HTTP response headersNSDictionary* info = (NSDictionary *) outputObject;}];[[QCloudCOSXMLService defaultCOSXML] DeleteBucketTagging:delReq];
let req = QCloudDeleteBucketTaggingRequest.init();// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket.req.bucket = "examplebucket-1250000000";req.finishBlock = { (result, error) inif let result = result {// result contains response headers} else {print(error!);}};QCloudCOSXMLService.defaultCOSXML().deleteBucketTagging(req);
Apakah halaman ini membantu?