查看PDF

设置桶的Website配置

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

功能说明

设置桶的Website配置。

方法定义

  1. func (obsClient ObsClient) SetBucketWebsiteConfiguration(input *SetBucketWebsiteConfigurationInput) (output *BaseModel, err error)

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

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

请求参数


参数名

类型

约束

input

*SetBucketWebsiteConfigurationInput

必选

返回结果


参数名

类型

output

*BaseModel

err

error

代码样例

  1. func main() {
  2. input := &obs.SetBucketWebsiteConfigurationInput{}
  3. input.Bucket = "bucketname"
  4. input.IndexDocument.Suffix = "suffix"
  5. input.ErrorDocument.Key = "key"
  6.  
  7. var routingRules [2]obs.RoutingRule
  8. routingRule0 := obs.RoutingRule{}
  9.  
  10. routingRule0.Redirect.HostName = "www.a.com"
  11. routingRule0.Redirect.Protocol = obs.ProtocolHttp
  12. routingRule0.Redirect.ReplaceKeyPrefixWith = "prefix"
  13. routingRule0.Redirect.HttpRedirectCode = "304"
  14. routingRules[0] = routingRule0
  15.  
  16. routingRule1 := obs.RoutingRule{}
  17.  
  18. routingRule1.Redirect.HostName = "www.b.com"
  19. routingRule1.Redirect.Protocol = obs.ProtocolHttps
  20. routingRule1.Redirect.ReplaceKeyWith = "replaceKey"
  21. routingRule1.Redirect.HttpRedirectCode = "304"
  22.  
  23. routingRule1.Condition.HttpErrorCodeReturnedEquals = "404"
  24. routingRule1.Condition.KeyPrefixEquals = "prefix"
  25.  
  26. routingRules[1] = routingRule1
  27.  
  28. input.RoutingRules = routingRules[:]
  29. output, err := obsClient.SetBucketWebsiteConfiguration(input)
  30. if err == nil {
  31. fmt.Printf("RequestId:%s\n", output.RequestId)
  32. } else {
  33. if obsError, ok := err.(obs.ObsError); ok {
  34. fmt.Println(obsError.Code)
  35. fmt.Println(obsError.Message)
  36. } else {
  37. fmt.Println(err)
  38. }
  39. }
  40. }

父主题:桶相关接口