GET Bucket policy
API Description
You can use this API to obtain the policy of a bucket.
Method Definition
func (obsClient ObsClient) GetBucketPolicy(bucketName string) (output *GetBucketPolicyOutput, err error)
Method Definition If a Signed URL Is Used
func (obsClient ObsClient) GetBucketPolicyWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *GetBucketPolicyOutput, err error)
Request Parameter
| Field | Type | Optional or Mandatory | Description |
|---|---|---|---|
| bucketName | string | Mandatory | Bucket name |
Returned Result
| Field | Type |
|---|---|
| output | |
| err | error |
Sample Code
func main() {
output, err := obsClient.GetBucketPolicy("bucketname")
if err == nil {
fmt.Printf("RequestId:%s\n", output.RequestId)
fmt.Printf("Policy:%s\n", output.Policy)
} else {
if obsError, ok := err.(obs.ObsError); ok {
fmt.Println(obsError.Code)
fmt.Println(obsError.Message)
} else {
fmt.Println(err)
}
}
} Last Article: PUT Bucket policy
Next Article: DELETE Bucket policy
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.