Updated on 2022-02-10 GMT+08:00

PUT Bucket tagging

API Description

You can use this API to set bucket tags.

Method Definition

ObsClient.setBucketTagging

Request Parameter

Field

Type

Optional or Mandatory

Description

Bucket

String

Mandatory

Bucket name

Tags

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',
       Tags : [{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);
              }
       }
});