GetBucketCors retrieves the Cross-Origin Resource Sharing (CORS) configuration from the bucket. If no CORS configuration exists, returns nil with no error. Parameters: - ctx: Context for request cancellation and timeout - bucketName: Name of the bucket Returns the CORS configuration or an error if
(ctx context.Context, bucketName string)
| 107 | // |
| 108 | // Returns the CORS configuration or an error if the operation fails. |
| 109 | func (c *Client) GetBucketCors(ctx context.Context, bucketName string) (*cors.Config, error) { |
| 110 | if err := s3utils.CheckValidBucketName(bucketName); err != nil { |
| 111 | return nil, err |
| 112 | } |
| 113 | bucketCors, err := c.getBucketCors(ctx, bucketName) |
| 114 | if err != nil { |
| 115 | errResponse := ToErrorResponse(err) |
| 116 | if errResponse.Code == NoSuchCORSConfiguration { |
| 117 | return nil, nil |
| 118 | } |
| 119 | return nil, err |
| 120 | } |
| 121 | return bucketCors, nil |
| 122 | } |
| 123 | |
| 124 | func (c *Client) getBucketCors(ctx context.Context, bucketName string) (*cors.Config, error) { |
| 125 | urlValues := make(url.Values) |
no test coverage detected