查看PDF

设置桶的事件通知配置

更新时间: 2019-03-13 10:29

功能说明

设置桶的事件通知配置,桶上所发生的指定操作,都能及时得到通知。

方法定义

  1. func (obsClient ObsClient) SetBucketNotification(input *SetBucketNotificationInput) (output *BaseModel, err error)

使用带授权信息URL的方法定义

  1. func (obsClient ObsClient) SetBucketNotificationWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header, data io.Reader) (output *BaseModel, err error)

请求参数


参数名

类型

约束

input

*SetBucketNotificationInput

必选

返回结果


参数名

类型

output

*BaseModel

err

error

代码样例

  1. func main() {
  2. input := &obs.SetBucketNotificationInput{}
  3. input.Bucket = "bucketname"
  4. var topicConfigurations [1]obs.TopicConfiguration
  5. topicConfigurations[0] = obs.TopicConfiguration{}
  6. topicConfigurations[0].ID = "001"
  7. topicConfigurations[0].Topic = "topic"
  8. topicConfigurations[0].Events = []obs.EventType{obs.ObjectCreatedAll}
  9.  
  10. var filterRules [2]obs.FilterRule
  11.  
  12. filterRules[0] = obs.FilterRule{Name: "prefix", Value: "smn"}
  13. filterRules[1] = obs.FilterRule{Name: "suffix", Value: ".jpg"}
  14. topicConfigurations[0].FilterRules = filterRules[:]
  15.  
  16. input.TopicConfigurations = topicConfigurations[:]
  17. output, err := obsClient.SetBucketNotification(input)
  18. if err == nil {
  19. fmt.Printf("RequestId:%s\n", output.RequestId)
  20. } else {
  21. if obsError, ok := err.(obs.ObsError); ok {
  22. fmt.Println(obsError.Code)
  23. fmt.Println(obsError.Message)
  24. } else {
  25. fmt.Println(err)
  26. }
  27. }
  28. }

父主题:桶相关接口