This implementation of the PUT operation uses the tagging subresource to add a set of tags to an existing bucket.
This operation is used to add tags to a bucket. Then, all CDRs generated by the requests for this bucket will take the same tags. Thus, CDR reports can be categorized for detailed cost analysis. For example, data is being uploaded to a bucket when an application is running. The application name can be tagged for this bucket. Use this tag to filter the CDRs generated by this application for analyzing its costs. However, searching for buckets by tag is not supported.
Only users granted the s3:PutBucketTagging permission can perform this operation. By default, the permission is granted to the bucket owner only. However, it can be granted to other users by configuring the bucket policy.
PUT /?tagging HTTP/1.1 User-Agent: agent Host: bucketname.obs.example.com Accept: */* Date: date Authorization: authorization string Content-MD5:<md5> Content-Length: length Expect: expect <Tagging> <TagSet> <Tag> <Key>Tag Name</Key> <Value>Tag Value</Value> </Tag> </TagSet> </Tagging>
This request contains no parameter.
Content-MD5 will be a required header for this operation. This request uses common headers. For details about common request headers, see section Common Request Headers.
In this request, you must configure the tags of buckets in the request body. The configurations of tags are uploaded in the XML format. The following table describes the elements to be configured.
Element |
Description |
Mandatory or Not |
---|---|---|
Tagging |
Container for the TagSet and Tag elements Type: Container Ancestor: None |
Yes |
TagSet |
Container for a set of tags Type: Container Ancestor: Tagging |
Yes |
Tag |
Container for tag information Type: Container. Each bucket supports a maximum of 20 tags. Ancestor: TagSet |
Yes |
Key |
Name of the tag Type: String. It can contain a maximum of 36 characters, including A to Z, a to z, 0 to 9, hyphens (-), underscores (_), and Unicode(\u4E00-\u9FFF). In the same bucket, the key of a tag must be unique. Ancestor: Tag |
Yes |
Value |
Value of the tag Type: String. It can contain a maximum of 43 characters, including A to Z, a to z, 0 to 9, hyphens (-), underscores (_), periods (.), and Unicode(\u4E00-\u9FFF). Note that periods (.) can be used for this parameter. Ancestor: Tag |
Yes |
HTTP/1.1 204 No Content Server: Server Name x-amz-request-id: request id x-amz-id-2: id x-reserved: amazon, aws and amazon web services are trademarks or registered trademarks of Amazon Technologies, Inc Date: date
This response uses common headers. For details about common response headers, see section Common Response Headers.
This response involves no elements.
Except for common error responses, special error responses are also returned. The following table lists error responses and possible causes.
Error Code |
Possible Cause |
HTTP Status Code |
---|---|---|
InvalidTag |
An invalid tag is provided when configuring a tag for a bucket. |
400 Bad Request |
MalformedXML |
The provided XML format is incorrect when configuring a bucket tag. |
400 Bad Request |
PUT /?tagging HTTP/1.1 User-Agent: curl/7.19.7 (x86_64-suse-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8j zlib/1.2.7 libidn/1.10 Host: bucketname.obs.example.com Accept: */* Date: Tue, 09 May 2017 02:41:20 +0000 Authorization: authorization string Content-MD5: 5yPl6Bu6q5Z6vBItpJAqAQ== Content-Length: 544 Expect: 100-continue <Tagging> <TagSet> <Tag> <Key>TagNameJJ1</Key> <Value>tytttasceettt</Value> </Tag> </TagSet> </Tagging>
HTTP/1.1 204 No Content Server: OBS x-amz-request-id: 0002B7532E0000015BEB146F2846E8E5 x-amz-id-2: a68r9ufCPuQCBUcwv1clom3zy/LsP+Bp+JJccmsmy2ptuwV3g0YMu3FIoTaEWA02 x-reserved: amazon, aws and amazon web services are trademarks or registered trademarks of Amazon Technologies, Inc Date: Tue, 09 May 2017 02:40:37 GMT