查看PDF

设置桶ACL

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

功能说明

设置桶的访问权限。

方法定义

  1. func (obsClient ObsClient) SetBucketAcl(input *SetBucketAclInput) (output *BaseModel, err error)

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

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

请求参数


参数名

类型

约束

input

*SetBucketAclInput

必选

返回结果


参数名

类型

output

*BaseModel

err

error

代码样例

  1. func main() {
  2. input := &obs.SetBucketAclInput{}
  3. input.Bucket = "bucketname"
  4. input.Owner.ID = "ownerid"
  5. var grants [3]obs.Grant
  6. grants[0].Grantee.Type = obs.GranteeGroup
  7. grants[0].Grantee.URI = obs.GroupAuthenticatedUsers
  8. grants[0].Permission = obs.PermissionRead
  9.  
  10. grants[1].Grantee.Type = obs.GranteeUser
  11. grants[1].Grantee.ID = "userid"
  12. grants[1].Permission = obs.PermissionWrite
  13.  
  14. grants[2].Grantee.Type = obs.GranteeUser
  15. grants[2].Grantee.ID = "userid"
  16. grants[2].Permission = obs.PermissionRead
  17. input.Grants = grants[0:3]
  18. output, err := obsClient.SetBucketAcl(input)
  19. if err == nil {
  20. fmt.Printf("RequestId:%s\n", output.RequestId)
  21. } else {
  22. if obsError, ok := err.(obs.ObsError); ok {
  23. fmt.Println(obsError.Code)
  24. fmt.Println(obsError.Message)
  25. } else {
  26. fmt.Println(err)
  27. }
  28. }
  29. }

父主题:桶相关接口