Obtaining CORS Rules of a Bucket
API Description
You can use this API to obtain the CORS rules of a specified bucket.
Method Definition
func (obsClient ObsClient) GetBucketCors(bucketName string) (output *GetBucketCorsOutput, err error)
Method Definition If a Signed URL Is Used
func (obsClient ObsClient) GetBucketCorsWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *GetBucketCorsOutput, 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.GetBucketCors("bucketname") if err == nil { fmt.Printf("RequestId:%s\n", output.RequestId) for _, corsRule := range output.CorsRules { fmt.Printf("ID:%s, AllowedOrigin:%s, AllowedMethod:%s, AllowedHeader:%s, MaxAgeSeconds:%d, ExposeHeader:%s\n", corsRule.ID, strings.Join(corsRule.AllowedOrigin, "|"), strings.Join(corsRule.AllowedMethod, "|"), strings.Join(corsRule.AllowedHeader, "|"), corsRule.MaxAgeSeconds, strings.Join(corsRule.ExposeHeader, "|")) } } else { if obsError, ok := err.(obs.ObsError); ok { fmt.Println(obsError.Code) fmt.Println(obsError.Message) } else { fmt.Println(err) } } }
Last Article: Configuring CORS Rules for a Bucket
Next Article: Deleting CORS Rules of a Bucket
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.