tencent cloud

Cloud Object Storage

Release Notes and Announcements
Release Notes
Announcements
Product Introduction
Overview
Features
Use Cases
Strengths
Concepts
Regions and Access Endpoints
Specifications and Limits
Service Regions and Service Providers
Billing
Billing Overview
Billing Method
Billable Items
Free Tier
Billing Examples
Viewing and Downloading Bill
Payment Overdue
FAQs
Getting Started
Console
Getting Started with COSBrowser
User Guide
Creating Request
Bucket
Object
Data Management
Batch Operation
Global Acceleration
Monitoring and Alarms
Operations Center
Data Processing
Content Moderation
Smart Toolbox
Data Processing Workflow
Application Integration
User Tools
Tool Overview
Installation and Configuration of Environment
COSBrowser
COSCLI (Beta)
COSCMD
COS Migration
FTP Server
Hadoop
COSDistCp
HDFS TO COS
GooseFS-Lite
Online Tools
Diagnostic Tool
Use Cases
Overview
Access Control and Permission Management
Performance Optimization
Accessing COS with AWS S3 SDK
Data Disaster Recovery and Backup
Domain Name Management Practice
Image Processing
Audio/Video Practices
Workflow
Direct Data Upload
Content Moderation
Data Security
Data Verification
Big Data Practice
COS Cost Optimization Solutions
Using COS in the Third-party Applications
Migration Guide
Migrating Local Data to COS
Migrating Data from Third-Party Cloud Storage Service to COS
Migrating Data from URL to COS
Migrating Data Within COS
Migrating Data Between HDFS and COS
Data Lake Storage
Cloud Native Datalake Storage
Metadata Accelerator
GooseFS
Data Processing
Data Processing Overview
Image Processing
Media Processing
Content Moderation
File Processing Service
File Preview
Troubleshooting
Obtaining RequestId
Slow Upload over Public Network
403 Error for COS Access
Resource Access Error
POST Object Common Exceptions
API Documentation
Introduction
Common Request Headers
Common Response Headers
Error Codes
Request Signature
Action List
Service APIs
Bucket APIs
Object APIs
Batch Operation APIs
Data Processing APIs
Job and Workflow
Content Moderation APIs
Cloud Antivirus API
SDK Documentation
SDK Overview
Preparations
Android SDK
C SDK
C++ SDK
.NET(C#) SDK
Flutter SDK
Go SDK
iOS SDK
Java SDK
JavaScript SDK
Node.js SDK
PHP SDK
Python SDK
React Native SDK
Mini Program SDK
Error Codes
Harmony SDK
Endpoint SDK Quality Optimization
Security and Compliance
Data Disaster Recovery
Data Security
Cloud Access Management
FAQs
Popular Questions
General
Billing
Domain Name Compliance Issues
Bucket Configuration
Domain Names and CDN
Object Operations
Logging and Monitoring
Permission Management
Data Processing
Data Security
Pre-signed URL Issues
SDKs
Tools
APIs
Agreements
Service Level Agreement
Privacy Policy
Data Processing And Security Agreement
Contact Us
Glossary

Object Tagging

PDF
Modo Foco
Tamanho da Fonte
Última atualização: 2024-01-23 17:15:08

Overview

This document provides an overview of APIs and SDK code samples for object tagging.
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.

SDK API References

For parameters and method description of all APIs in the SDK, see SDK API Reference.

Tagging an Object

Feature description

This API is used to set tags for an existing object. It can help you group and manage existing object resources by adding key-value pairs as object tags.

Sample code

Objective-C

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 tags
QCloudTagging *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 slashes
tag1.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 slashes
tag1.value = @"20";
QCloudTag *tag2 = [QCloudTag new];
tag2.key = @"name";
tag2.value = @"karis";

// Set of tags. Up to 10 tags are supported
QCloudTagSet *tagSet = [QCloudTagSet new];
tagSet.tag = @[tag1,tag2];
taggings.tagSet = tagSet;

// Set of tags
putReq.taggings = taggings;

[putReq setFinishBlock:^(id outputObject, NSError *error) {
// outputObject contains all the HTTP response headers
NSDictionary* info = (NSDictionary *) outputObject;
}];
[[QCloudCOSXMLService defaultCOSXML] PutObjectTagging:putReq];
Swift
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/bucket
putReq.bucket = "examplebucket-1250000000";

// Set of tags
let 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 slashes
tag1.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 slashes
tag1.value = "20";
let tag2 = QCloudTag();
tag2.key = "name";
tag2.value = "karis";

// Set of tags. Up to 10 tags are supported
let tagSet = QCloudTagSet();
tagSet.tag = [tag1,tag2];
taggings.tagSet = tagSet;

// Set of tags
putReq.taggings = taggings;

req.finishBlock = {(result,error) in
if let result = result {
// result contains response headers
} else {
print(error!);
}
}
QCloudCOSXMLService.defaultCOSXML().putObjectTagging(putReq);

Querying Object Tags

Feature description

This API is used to query the existing tags of a specified object.

Sample code

Objective-C
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 tags
QCloudTagSet * tagSet = result.tagSet;
}];
[[QCloudCOSXMLService defaultCOSXML] GetObjectTagging:getReq];
Swift
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/bucket
getReq.bucket = "examplebucket-1250000000";

req.finishBlock = {(result,error) in
if let result = result {
// Set of tags
let tagSet = result.tagSet;
} else {
print(error!);
}
}

QCloudCOSXMLService.defaultCOSXML().getObjectTagging(getReq);

Deleting Object Tags

Note:
The COS iOS SDK version should be v5.9.9 or higher.

Feature description

This API is used to delete the existing tags of a specified object.

Sample request

Objective-C
QCloudDeleteObjectTaggingRequest *request = [QCloudDeleteObjectTaggingRequest new];

// File name
request.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";

[request setFinishBlock:^(id * result, NSError * error) {

if(!error){
// Deletion succeed
}else{
// Deletion failed
}
}];
[[QCloudCOSXMLService defaultCOSXML] DeleteObjectTagging:request];
Swift
let request = QCloudDeleteObjectTaggingRequest();

// File name
request.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) in
if(!error){
// Deletion succeed
}else{
// Deletion failed
}
}

QCloudCOSXMLService.defaultCOSXML().deleteObjectTagging(request);


Ajuda e Suporte

Esta página foi útil?

comentários