• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. API Reference (Node.js SDK)
  4. Bucket-Related APIs
  5. PUT Bucket tagging

PUT Bucket tagging

API Description

You can use this API to set bucket tags.

Method Definition

ObsClient.setBucketTagging(parameter, callback)

Request Parameter

Field

Type

Optional or Mandatory

Description

Bucket

String

Mandatory

Bucket name

TagSet

Object

Mandatory

Bucket tag set

  

Tag

Array

Mandatory

Bucket tag set

  

Key

String

Mandatory

Tag name, which contains 1 to 36 characters and cannot include non-printable ASCII characters (0–31) and the following special characters: *<>\= The tag keys in one bucket must be unique.

Value

String

Mandatory

Tag value, which can contain up to 43 characters and cannot include non-printable ASCII characters (0–31) and the following special characters: *<>\=

Returned Result (InterfaceResult)

Field

Type

Description

RequestId

String

Request ID returned by the OBS server

Sample Code

obsClient.setBucketTagging({
       Bucket : 'bucketname',
       TagSet : {
              Tag :[{Key:'tag1', Value : 'value1'}, {Key:'tag2', Value : 'value2'}]
       }
},(err, result) => {
       if(err){
              console.error('Error-->' + err);
       }else{
              if(result.CommonMsg.Status < 300){
                     console.log('RequestId-->' + result.InterfaceResult.RequestId);
              }else{
                     console.log('Code-->' + result.CommonMsg.Code);
                     console.log('Message-->' + result.CommonMsg.Message);
              }
       }
});