Listing Buckets

If you have any questions during development, post them on the Issues page of GitHub. For details about parameters and usage of each API, see the API Reference

You can call ObsClient.listBuckets to list buckets. Sample code is as follows:

String endPoint = "https://your-endpoint";
String ak = "*** Provide your Access Key ***";
String sk = "*** Provide your Secret Key ***";
// Create an instance of ObsClient.
ObsClient obsClient = new ObsClient(ak, sk, endPoint);

// List buckets.
ListBucketsRequest request = new ListBucketsRequest();
request.setQueryLocation(true);
List<ObsBucket> buckets = obsClient.listBuckets(request);
for(ObsBucket bucket : buckets){
    System.out.println("BucketName:" + bucket.getBucketName());
    System.out.println("CreationDate:" + bucket.getCreationDate());
    System.out.println("Location:" + bucket.getLocation());
}
  • Obtained bucket names are listed in the lexicographical order.
  • Set ListBucketsRequest.setQueryLocation to true and then you can query the bucket location when listing buckets.