GET Buckets
API Description
You can use this API to obtain the bucket list. In the list, bucket names are displayed in lexicographical order.
Method Definition
ObsClient.listBuckets
Request Parameter
Field |
Type |
Optional or Mandatory |
Description |
---|---|---|---|
QueryLocation |
Boolean |
Optional |
Whether to query the bucket location |
Returned Result (InterfaceResult)
Field |
Type |
Description |
||
---|---|---|---|---|
RequestId |
String |
Request ID returned by the OBS server |
||
Buckets |
Array |
Bucket list |
||
BucketName |
String |
Bucket name |
||
CreationDate |
String |
Creation time of the bucket |
||
Location |
String |
Bucket location |
||
Owner |
Object |
Bucket owner |
||
ID |
String |
ID of the domain to which the bucket owner belongs |
Sample Code
obsClient.listBuckets({ QueryLocation: true },(err, result) => { if(err){ console.error('Error-->' + err); }else{ if(result.CommonMsg.Status < 300){ console.log('RequestId-->' + result.InterfaceResult.RequestId); console.log('Owner:'); console.log('ID-->' + result.InterfaceResult.Owner.ID); console.log('Buckets:'); for(let i=0;i<result.InterfaceResult.Buckets.Bucket.length;i++){ console.log('Bucket[' + i + ']:'); console.log('BucketName-->' + result.InterfaceResult.Buckets[i].BucketName); console.log('CreationDate-->' + result.InterfaceResult.Buckets[i].CreationDate); console.log('Location-->' + result.InterfaceResult.Buckets[i].Location); } }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.