• Object Storage Service

  1. Help Center
  2. Object Storage Service
  3. Developer Guide (Java SDK)
  4. Bucket Management
  5. Obtaining Bucket Metadata

Obtaining Bucket Metadata

You can call ObsClient.getBucketMetadata to obtain the metadata of a bucket. Sample code is as follows:

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

BucketMetadataInfoRequest request = new BucketMetadataInfoRequest("bucketname");
// Obtain the bucket metadata.
BucketMetadataInfoResult result = obsClient.getBucketMetadata(request);
System.out.println("\t:" + result.getDefaultStorageClass());
System.out.println("\t:" + result.getAllowOrigin());
System.out.println("\t:" + result.getMaxAge());
System.out.println("\t:" + result.getAllowHeaders());
System.out.println("\t:" + result.getAllowMethods());
System.out.println("\t:" + result.getExposeHeaders());
// Close obsClient.

For details about values of methods, such as BucketMetadataInfoResult.getAllowMethods, see the CORS configurations of the bucket.