Baidu AI Cloud
中国站

百度智能云

Object Storage

Get a CORS Rule Set on Specified Bucket

Interface Description

This interface is used to get the current CORS rule of the specified bucket.

Permission Description: Only the bucket owner and the user with the FULL_CONTROL permission can set the CORS rules of the bucket. If users have no permission, it returns “403 Forbidden: AccessDenied.

Request URI

GET /v1/{bucketName}/?cors

Parameter Name Parameter Type Required Description Example Value Parameter Position
bucketName String Yes Bucket name "bucketName_example" Path

Request Body Parameters

Instructions for Data Structure of Request Body Field

Parameter Name Parameter Type Required Description Example Value
corsConfiguration List Yes CORS rules container of the bucket. Each bucket can possess up to 100 rules. If there are multiple configurations, they are executed from top to bottom.

Data Structure Description of CorsConfiguration Field

Parameter Name Parameter Type Required Description Example Value
allowedOrigins List Yes Container for storing the origin of the cross-origin requests allowed
allowedMethods List Yes Container for storing the cross-origin request method allowed
allowedHeaders List Yes Container for storing the allowedHeaders It controls whether the header specified in Access-Control-Request-Headers in the OPTIONS prefetch instruction is allowed.
allowedExposeHeaders List No Container for storing the response headers that are allowed to access from the application by users
maxAgeSeconds Integer No Specify the time for the browser to cache the prefetch request return results (OPTIONS) of specific resources. The requester does not need to send duplicate preflight requests within the cache time expressed in seconds. Type:Int64. 1800

Response Body Parameters

Instructions for Data Structure of Response Body Field

Parameter name Parameter Type Description Example Value
corsConfiguration List CORS rules container of the bucket. Each bucket can possess up to 100 rules. If there are multiple configurations, they are executed from top to bottom.

Data Structure Description of CorsConfiguration Field

Parameter Name Parameter Type Description Example Value
allowedOrigins List Container for storing the origin of the cross-origin requests allowed
allowedMethods List Container for storing the cross-origin request method allowed
allowedHeaders List Container for storing the allowedHeaders It controls whether the header specified in Access-Control-Request-Headers in the OPTIONS prefetch instruction is allowed.
allowedExposeHeaders List Container for storing the response headers that are allowed to access from the application by users
maxAgeSeconds Long Specify the time for the browser to cache the prefetch request return results (OPTIONS) of specific resources. The requester does not need to send duplicate preflight requests within the cache time expressed in seconds. Type:Int64. 1800

Request Example

GET /v1/bucketName_example/?cors
Common Request Header


{
  "corsConfiguration" : [ {
    "allowedExposeHeaders" : [ "user-custom-expose-header" ],
    "allowedOrigins" : [ "http://www.example.com" ],
    "allowedHeaders" : [ "Authorization" ],
    "allowedMethods" : [ "GET" ],
    "maxAgeSeconds" : 1800
  } ]
}

Response Example

HTTP/1.1 200 OK
<Common response header>

{
  "corsConfiguration" : [ {
    "allowedExposeHeaders" : [ "user-custom-expose-header", "user-custom-expose-header" ],
    "allowedOrigins" : [ "http://www.example.com", "http://www.example.com" ],
    "allowedHeaders" : [ "Authorization", "Authorization" ],
    "allowedMethods" : [ "GET", "GET" ],
    "maxAgeSeconds" : 1800
  }, {
    "allowedExposeHeaders" : [ "user-custom-expose-header", "user-custom-expose-header" ],
    "allowedOrigins" : [ "http://www.example.com", "http://www.example.com" ],
    "allowedHeaders" : [ "Authorization", "Authorization" ],
    "allowedMethods" : [ "GET", "GET" ],
    "maxAgeSeconds" : 1800
  } ]
}

Error Code

Refer to the universal error code.

Previous
Disable a CORS Rule Set on Specified Bucket
Next
Set a CORS Rule on Specified Bucket