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 |
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. |
|
ExposeHeader |
Array of Strings |
Additional response headers allowed by the CORS rule |
Sample Code
obsClient.getBucketCors({ Bucket : 'bucketname' },(err, result) => { if(err){ console.error('Error-->' + err); }else{ if(result.CommonMsg.Status < 300){ console.log('RequestId-->' + result.InterfaceResult.RequestId); for(let 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 (let i=0;i<result.InterfaceResult.CorsRules[k]['AllowedMethod'].length;i++){ console.log('CorsRule[AllowedMethod][' , i ,']-->'+result.InterfaceResult.CorsRules[k]['AllowedMethod'][i]); } for(let i=0;i< result.InterfaceResult.CorsRules[k]['AllowedOrigin'].length;i++){ console.log('CorsRule[AllowedOrigin][',i ,']-->'+result.InterfaceResult.CorsRules[k]['AllowedOrigin'][i]); } for(let i=0;i<result.InterfaceResult.CorsRules[k]['AllowedHeader'].length;i++){ console.log('CorsRule[AllowedHeader][',i,']-->'+result.InterfaceResult.CorsRules[k]['AllowedHeader'][i]); } for(let 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.