设置桶的Website配置
更新时间: 2019-03-13 10:19
功能说明
设置桶的Website配置。
方法定义
- func (obsClient ObsClient) SetBucketWebsiteConfiguration(input *SetBucketWebsiteConfigurationInput) (output *BaseModel, err error)
使用带授权信息URL的方法定义
- func (obsClient ObsClient) SetBucketWebsiteConfigurationWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header, data io.Reader) (output *BaseModel, err error)
请求参数
参数名 | 类型 | 约束 |
---|---|---|
input | *SetBucketWebsiteConfigurationInput | 必选 |
返回结果
参数名 | 类型 |
---|---|
output | *BaseModel |
err | error |
代码样例
- func main() {
- input := &obs.SetBucketWebsiteConfigurationInput{}
- input.Bucket = "bucketname"
- input.IndexDocument.Suffix = "suffix"
- input.ErrorDocument.Key = "key"
- var routingRules [2]obs.RoutingRule
- routingRule0 := obs.RoutingRule{}
- routingRule0.Redirect.HostName = "www.a.com"
- routingRule0.Redirect.Protocol = obs.ProtocolHttp
- routingRule0.Redirect.ReplaceKeyPrefixWith = "prefix"
- routingRule0.Redirect.HttpRedirectCode = "304"
- routingRules[0] = routingRule0
- routingRule1 := obs.RoutingRule{}
- routingRule1.Redirect.HostName = "www.b.com"
- routingRule1.Redirect.Protocol = obs.ProtocolHttps
- routingRule1.Redirect.ReplaceKeyWith = "replaceKey"
- routingRule1.Redirect.HttpRedirectCode = "304"
- routingRule1.Condition.HttpErrorCodeReturnedEquals = "404"
- routingRule1.Condition.KeyPrefixEquals = "prefix"
- routingRules[1] = routingRule1
- input.RoutingRules = routingRules[:]
- output, err := obsClient.SetBucketWebsiteConfiguration(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)
- }
- }
- }
父主题:桶相关接口