API | Operation | Description |
Tagging an object | Tags an uploaded object. | |
Querying object tags | Queries all tags of an object. | |
Deleting object tags | Deletes all tags of an object. |
QCloudPutObjectTaggingRequest *putReq = [QCloudPutObjectTaggingRequest 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] PutObjectTagging:putReq];
let putReq = QCloudPutObjectTaggingRequest()// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketputReq.bucket = "examplebucket-1250000000";// Set of tagslet taggings = QCloudTagging();let tag1 = QCloudTag();// 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();tag2.key = "name";tag2.value = "karis";// Set of tags. Up to 10 tags are supportedlet tagSet = QCloudTagSet();tagSet.tag = [tag1,tag2];taggings.tagSet = tagSet;// Set of tagsputReq.taggings = taggings;req.finishBlock = {(result,error) inif let result = result {// result contains response headers} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().putObjectTagging(putReq);
QCloudGetObjectTaggingRequest *getReq = [QCloudGetObjectTaggingRequest 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:^(QCloudTagging * result, NSError * error) {// Set of tagsQCloudTagSet * tagSet = result.tagSet;}];[[QCloudCOSXMLService defaultCOSXML] GetObjectTagging:getReq];
let getReq = QCloudGetObjectTaggingRequest();// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketgetReq.bucket = "examplebucket-1250000000";req.finishBlock = {(result,error) inif let result = result {// Set of tagslet tagSet = result.tagSet;} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().getObjectTagging(getReq);
QCloudDeleteObjectTaggingRequest *request = [QCloudDeleteObjectTaggingRequest new];// File namerequest.object = @"test.png";// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketrequest.bucket = @"examplebucket-1250000000";request.versionId = @"versionId";[request setFinishBlock:^(id * result, NSError * error) {if(!error){// Deletion succeed}else{// Deletion failed}}];[[QCloudCOSXMLService defaultCOSXML] DeleteObjectTagging:request];
let request = QCloudDeleteObjectTaggingRequest();// File namerequest.object = "test.png";// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket.request.bucket = "examplebucket-1250000000";request.versionId = "versionId";req.finishBlock = {(result,error) inif(!error){// Deletion succeed}else{// Deletion failed}}QCloudCOSXMLService.defaultCOSXML().deleteObjectTagging(request);
Apakah halaman ini membantu?