Configuring the Event Notifications for a Bucket
API Description
You can use this API to configure the event notifications for a bucket. You will be notified of all specified operations performed on the bucket.
Method Definition
func (obsClient ObsClient) SetBucketNotification(input *SetBucketNotificationInput) (output *BaseModel, err error)
Method Definition If a Signed URL Is Used
func (obsClient ObsClient) SetBucketNotificationWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header, data io.Reader) (output *BaseModel, err error)
Request Parameter
| Field | Type | Optional or Mandatory |
|---|---|---|
| input | Mandatory |
Returned Result
| Field | Type |
|---|---|
| output | |
| err | error |
Sample Code
func main() { input := &obs.SetBucketNotificationInput{} input.Bucket = "bucketname" var topicConfigurations [1]obs.TopicConfiguration topicConfigurations[0] = obs.TopicConfiguration{} topicConfigurations[0].ID = "001" topicConfigurations[0].Topic = "topic" topicConfigurations[0].Events = []obs.EventType{obs.ObjectCreatedAll} var filterRules [2]obs.FilterRule filterRules[0] = obs.FilterRule{Name: "prefix", Value: "smn"} filterRules[1] = obs.FilterRule{Name: "suffix", Value: ".jpg"} topicConfigurations[0].FilterRules = filterRules[:] input.TopicConfigurations = topicConfigurations[:] output, err := obsClient.SetBucketNotification(input) if err == nil { fmt.Printf("RequestId:%s\n", output.RequestId) } else { if obsError, ok := err.(obs.ObsError); ok { fmt.Println(obsError.Code) fmt.Println(obsError.Message) } else { fmt.Println(err) } } }
Last Article: Deleting CORS Rules of a Bucket
Next Article: Obtaining the Event Notification Settings of a Bucket
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.