• Object Storage Service

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

PUT Bucket notification

API Description

You can use this API to set event notification for a bucket. The user will be notified of all specified operations performed on the bucket.

Method Definition

ObsClient.setBucketNotification(parameter, callback)

Request Parameter

Field

Type

Optional or Mandatory

Description

Bucket

String

Mandatory

Bucket name

TopicConfigurations

Array

Optional

Event notification setting list of the bucket

  

ID

String

Optional

Event notification setting ID

Topic

String

Mandatory

URN of the event notification topic. After detecting a specific event in a bucket, OBS sends a message to the topic.

Event

Array

Mandatory

Type of events that need to be notified. Possible values are:

  • s3:ObjectCreated:*
  • s3:ObjectCreated:Put
  • s3:ObjectCreated:Post
  • s3:ObjectCreated:Copy
  • s3:ObjectCreated:CompleteMultipartUpload
  • s3:ObjectRemoved:*
  • s3:ObjectRemoved:Delete
  • s3:ObjectRemoved:DeleteMarkerCreated

Filter

Object

Optional

Filtering rule information

  

FilterRule

Array

Optional

List of filtering rules

  

Name

String

Optional

Prefix or suffix of object names for filtering. Possible values are:

  • prefix
  • suffix

Value

String

Optional

Keyword of object name for filtering objects by prefix or suffix

Returned Result (InterfaceResult)

Field

Type

Description

RequestId

String

Request ID returned by the OBS server

Sample Code

obsClient.setBucketNotification({
       Bucket : 'bucketname',
       TopicConfigurations : [
           {
                  ID : '001',
                  Topic : 'urn:smn:region:xxxx:topic1',
                  Event : ['s3:ObjectCreated:*'],
                  Filter : {
                         FilterRule :[{Name : 'prefix', Value: 'smn'}, {Name : 'suffix', Value: '.jpg'}]
                  }
           }
       ]
},(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);
              }
       }
});