GET Bucket cors
API Description
You can use this API to obtain the CORS rules of a specified bucket.
Method Definition
ObsClient.getBucketCors
Request Parameter
Field |
Type |
Optional or Mandatory |
Description |
---|---|---|---|
Bucket |
String |
Mandatory |
Bucket name |
RequestDate |
String or Date |
Optional |
Request time
NOTE:
When the parameter type is String, the value must comply with the ISO8601 or RFC822 standards. |
Returned Result (InterfaceResult)
Field |
Type |
Description |
|
---|---|---|---|
RequestId |
String |
Request ID returned by the OBS server |
|
CorsRules |
Array |
CORS rules of the bucket |
|
ID |
String |
CORS rule ID |
|
AllowedMethod |
Array of Strings |
HTTP methods allowed by the CORS rule |
|
AllowedOrigin |
Array of Strings |
Origins (character strings representing domain names) allowed by the CORS rule. |
|
AllowedHeader |
Array of Strings |
Request headers allowed by the CORS rule |
|
MaxAgeSeconds |
String |
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 |
Array of Strings |
Additional response headers allowed by the CORS rule |
Sample Code
obsClient.getBucketCors({ Bucket : 'bucketname' }, function(err, result) { if(err){ console.error('Error-->' + err); }else{ if(result.CommonMsg.Status < 300){ console.log('RequestId-->' + result.InterfaceResult.RequestId); for(var k=0;k<result.InterfaceResult.CorsRules.length;k++){ console.log('CorsRule[',k,']'); console.log('CorsRule[ID]-->' + result.InterfaceResult.CorsRules[k]['ID']); console.log('CorsRule[MaxAgeSeconds]-->' + result.InterfaceResult.CorsRules[k]['MaxAgeSeconds']); for (var i=0;i<result.InterfaceResult.CorsRules[k]['AllowedMethod'].length;i++){ console.log('CorsRule[AllowedMethod][' , i ,']-->'+result.InterfaceResult.CorsRules[k]['AllowedMethod'][i]); } for(var i=0;i< result.InterfaceResult.CorsRules[k]['AllowedOrigin'].length;i++){ console.log('CorsRule[AllowedOrigin][',i ,']-->'+result.InterfaceResult.CorsRules[k]['AllowedOrigin'][i]); } for(var i=0;i<result.InterfaceResult.CorsRules[k]['AllowedHeader'].length;i++){ console.log('CorsRule[AllowedHeader][',i,']-->'+result.InterfaceResult.CorsRules[k]['AllowedHeader'][i]); } for(var i=0;i<result.InterfaceResult.CorsRules[k]['ExposeHeader'].length;i++){ console.log('CorsRule[ExposeHeader][',i ,']-->'+result.InterfaceResult.CorsRules[k]['ExposeHeader'][i]); } } }else{ console.log('Code-->' + result.CommonMsg.Code); console.log('Message-->' + result.CommonMsg.Message); } } });
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