Obtain Bucket Metadata
API Description
You can use this API to send a HEAD request to a bucket to obtain the bucket metadata such as storage class and CORS rules (if set).
Method Definition
ObsClient.getBucketMetadata
Request Parameter
Field |
Type |
Optional or Mandatory |
Description |
---|---|---|---|
Bucket |
String |
Mandatory |
Bucket name |
Origin |
String |
Optional |
Origin of the cross-domain request specified by the pre-request. Generally, it is a domain name. |
RequestHeader |
String |
Optional |
HTTP headers in the cross-domain request |
Returned Result (InterfaceResult)
Field |
Type |
Description |
---|---|---|
RequestId |
String |
Request ID returned by the OBS server |
StorageClass |
String |
Storage class of the bucket. When the storage class is OBS Standard, the value is null. |
Location |
String |
Bucket location |
ObsVersion |
String |
OBS server version |
AllowOrigin |
String |
If Origin in the request meets the CORS rule of the server, AllowedOrigin in the CORS configuration of the server is returned. |
AllowHeader |
String |
If RequestHeader in the request meets the CORS rule of the server, AllowedHeader in the CORS configuration of the server is returned. |
AllowMethod |
String |
AllowedMethod in the CORS rule of the server |
ExposeHeader |
String |
ExposeHeader in the CORS rule of the server |
MaxAgeSeconds |
String |
MaxAgeSeconds in the CORS rule of the server |
Sample Code
obsClient.getBucketMetadata({ Bucket : 'bucketname', Origin : 'http://www.a.com', RequestHeader : 'x-obs-header' },(err, result) => { if(err){ console.error('Error-->' + err); }else{ if(result.CommonMsg.Status < 300){ console.log('RequestId-->' + result.InterfaceResult.RequestId); console.log('StorageClass-->' + result.InterfaceResult.StorageClass); console.log('Location-->' + result.InterfaceResult.Location); console.log('AllowOrigin-->' + result.InterfaceResult.AllowOrigin); console.log('AllowHeaders-->' + result.InterfaceResult.AllowHeader); console.log('AllowMethods-->' + result.InterfaceResult.AllowMethod); console.log('MaxAgeSeconds-->' + result.InterfaceResult.MaxAgeSeconds); console.log('ExposeHeaders-->' + result.InterfaceResult.ExposeHeader); }else{ console.log('Status-->' + result.CommonMsg.Status); } } });
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