-
API Reference
- Overview
- Initialization
- Predefined Constants
-
Bucket-Related APIs
- PUT Bucket
- GET Buckets
- HEAD Bucket
- DELETE Bucket
- GET Objects
- GET Object versions
- List Multipart uploads
- Obtain Bucket Metadata
- GET Bucket location
- GET Bucket storageinfo
- PUT Bucket quota
- GET Bucket quota
- Set Bucket storagePolicy
- GET Bucket storagePolicy
- PUT Bucket acl
- GET Bucket acl
- PUT Bucket logging
- GET Bucket logging
- PUT Bucket policy
- GET Bucket policy
- DELETE Bucket policy
- PUT Bucket lifecycle
- GET Bucket lifecycle
- DELETE Bucket lifecycle
- PUT Bucket website
- GET Bucket website
- DELETE Bucket website
- PUT Bucket versioning
- GET Bucket versioning
- PUT Bucket cors
- GET Bucket cors
- DELETE Bucket cors
- PUT Bucket tagging
- GET Bucket tagging
- DELETE Bucket tagging
- Objects-Related APIs
- Other APIs
- Change History
- General Reference
Copied.
GET Bucket cors
API Description
You can use this API to obtain the CORS rules of a specified bucket.
Method Definition
1. ObsClient->setBucketCors(array $parameter) 2. ObsClient->setBucketCorsAsync(array $parameter, callable $callback)
Request Parameter
Field |
Type |
Optional or Mandatory |
Description |
---|---|---|---|
Bucket |
string |
Mandatory |
Bucket name |
Returned Result
Field |
Type |
Description |
|
---|---|---|---|
HttpStatusCode |
integer |
HTTP status code |
|
Reason |
string |
Reason description |
|
RequestId |
string |
Request ID returned by the OBS server |
|
CorsRules |
indexed array |
CORS rules of the bucket |
|
ID |
string |
CORS rule ID |
|
AllowedMethod |
indexed array of strings |
HTTP methods allowed by the CORS rule |
|
AllowedOrigin |
indexed array of strings |
Origins (character strings representing domain names) allowed by the CORS rule |
|
AllowedHeader |
indexed array of strings |
Request headers allowed by the CORS rule |
|
MaxAgeSecond |
integer |
Cache duration (in seconds) of the cross-region request result in the client allowed by the CORS rule. The value must be an integer. |
|
ExposeHeader |
indexed array of strings |
Additional response headers allowed by the CORS rule |
Sample Code
try{ $resp = $obsClient -> getBucketCors([ 'Bucket' => 'bucketname' ]); printf("RequestId:%s\n", $resp['RequestId']); foreach ($resp['CorsRules'] as $index => $corsRule){ printf("CorsRule[%d]\n", $index + 1); printf("MaxAgeSeconds:%s\n", print_r($corsRule['MaxAgeSeconds'], true)); printf("AllowedMethod:%s\n", print_r($corsRule['AllowedMethod'], true)); printf("AllowedOrigin:%s\n", print_r($corsRule['AllowedOrigin'], true)); printf("AllowedHeader:%s\n", print_r($corsRule['AllowedHeader'], true)); printf("ExposeHeader:%s\n", print_r($corsRule['ExposeHeader'],true)); } }catch (Obs\Common\ObsException $obsException){ printf("ExceptionCode:%s\n", $obsException->getExceptionCode()); printf("ExceptionMessage:%s\n", $obsException->getExceptionMessage()); }
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot