Configuring a Bucket Policy
API Description
You can use this API to set a bucket policy. If the bucket already has a policy, the policy will be overwritten by the one specified in this request.
Method Definition
func (obsClient ObsClient) SetBucketPolicy(input *SetBucketPolicyInput) (output *BaseModel, err error)
Method Definition If a Signed URL Is Used
func (obsClient ObsClient) SetBucketPolicyWithSignedUrl(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.SetBucketPolicyInput{} input.Bucket = "bucketname" input.Policy = "your policy" output, err := obsClient.SetBucketPolicy(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: Obtaining Logging Configuration of a Bucket
Next Article: Obtaining a Bucket Policy
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.