Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Cloud Data Center
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Domain Name Service
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
DataArts Studio
Data Warehouse Service
Cloud Search Service
DataArts Lake Formation
DataArts Fabric
Data Ingestion Service
Data Lake Visualization
Data Lake Factory
IoT
IoT Device Access
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Industry Video Management Service
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
Huawei Cloud Astro Canvas
Huawei Cloud Astro Zero
CodeArts Governance
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Business Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance (CCI)
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Meeting
AI
ModelArts
PanguLargeModels
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Cloud Transformation
Cloud Adoption Framework
Well-Architected Framework
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Blockchain
Blockchain Service
Web3 Node Engine Service
MacroVerse aPaaS
CloudDevice
KooDrive

Adding Object Tags

Updated on 2025-03-11 GMT+08:00

Functions

This operation adds or updates the tag information for an object. An object tag is a key-value pair.

If you do not specify a version ID in a request, make sure that you have the PutObjectTagging permission. If you do specify a version ID in a request, make sure that you have the PutObjectTagging and PutObjectVersionTagging permissions. By default, only the object owner can perform this operation. The object owner can grant this permission to others by using a bucket or user policy.

Tags are added to the current version of an object by default. You can use the versionId parameter to add tags to any other version. If the version you are adding tags to is a delete marker, OBS returns 404 Not Found.

NOTE:
  • Tags cannot be set for files in parallel file systems.
  • An object can have up to 10 tags.
  • Constraints on the tag key and value:

    A tag key is case sensitive and must be unique. It cannot be left blank or exceed 128 characters. The following characters are not allowed: =*<>\,|/?!;

    A tag value is case sensitive and can be left blank. It cannot exceed 255 characters. The following characters are not allowed: =*<>\,|?!;

Request Syntax

PUT /objectname?tagging&versionId=versionid HTTP/1.1
Date: date
Authorization: authorization string
Content-MD5: md5
<?xml version="1.0" encoding="UTF-8">
<Tagging>
    <TagSet>
        <Tag>
            <Key>Key</Key>
            <Value>Value</Value>
        </Tag>
     </TagSet> 
</Tagging>

Request Parameters

Table 1 describes the parameters in the request.

Table 1 Request parameters

Parameter

Description

Mandatory

tagging

Indicates an object tagging request.

Type: string

Yes

versionId

ID of the object version that the tag will be added to. Its response header is x-obs-version-id.

Type: string

No

Request Headers

Table 2 describes the headers in the request.

Table 2 Request headers

Header

Description

Mandatory

Content-MD5

Base64-encoded 128-bit MD5 digest of the message according to RFC 1864. You can also configure the Content-SHA256 header whose value is the Base64-encoded SHA-256 digest of the message. Configure either Content-MD5 or Content-SHA256.

Type: string

Example: n58IG6hfM7vqI4K0vnWpog==

Yes

Request Elements

In this request body, you need to configure the object tags in XML. Table 3 describes the tag elements to be configured.

Table 3 Object tag elements

Header

Description

Mandatory

Tagging

Root element for TagSet and Tag

Type: container

Parent: none

Yes

TagSet

A collection for a set of tags.

Type: container

Parent: Tagging

Yes

Tag

Information element of Tag

Type: container

Parent: TagSet

Yes

Key

Tag name

Type: string

Parent: Tag

Yes

Value

Tag value

Type: string

Parent: Tag

Yes

Response Syntax

1
2
3
4
5
HTTP/1.1 status_code
x-obs-request-id: request id
x-obs-id-2: id
Content-Length: length
Date: date

Response Headers

This response uses common headers. For details, see Table 1.

Response Elements

This response contains no elements.

Error Responses

In addition to common error codes, this API also returns others. Table 4 lists the common errors and possible causes.

Table 4 Error codes of object tagging

Error Code

Description

HTTP Status Code

InvalidTag

The provided object tag was invalid.

400

BadRequest

The number of object tags exceeded the upper limit.

400

MalformedXML

The XML file was malformed.

400

EntityTooLarge

The request body was too long.

400

AccessDenied

No permission to configure object tags.

403

MethodNotAllowed

Method not allowed, because the corresponding feature was not enabled.

405

Sample Request

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
PUT /objectname?tagging&versionId=G001018455096CE600005306000000DD HTTP/1.1
User-Agent: curl/7.29.0
Accept: */*
Date: Wed, 27 Jun 2018 13:22:50 GMT
Authorization: OBS H4IPJX0TQTHTHEBQQCEC:Pf1ZyGvVYg2BzOjokZ/BAeR1mEQ=
Content-SHA256: ogX9qClMrVJUBiUSIKDFM0qO41jJM0I5SCN55/OtMyI=
Content-Length: 182
  <TagSet>
    <Tag>
      <Key>TagName1</Key>
      <Value>TageSetVaule1</Value>
    </Tag>
  </TagSet>
</Tagging>

Sample Response

1
2
3
4
5
HTTP/1.1 200 OK
Server: OBS
x-obs-request-id: BF26000001643FEBA09B1ED46932CD07
x-obs-id-2: 32AAAQAAEAABSAAgAAEAABAAAQAAEAABCSEZp87iEirC6DggPB5cN49pSvHBWClg
Date: Wed, 27 Jun 2018 13:22:50 GMT

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback
咨询盘古Doer

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback