A bucket is a container for objects stored in OSS. Every object is contained in a bucket. This topic describes how to query information about a bucket.

The following code provides an example on how to query the information about a bucket, including the region, creation date, and ACL of the bucket.

// This example uses the endpoint of the China (Hangzhou) region. Specify the actual endpoint based on your requirements.
String endpoint = "http://oss-cn-hangzhou.aliyuncs.com";
// Security risks may arise if you use the AccessKey pair of an Alibaba Cloud account to log on to OSS, because the account has permissions on all API operations. We recommend that you use your RAM user's credentials to call API operations or perform routine operations and maintenance. To create your RAM user, log on to https://ram.console.aliyun.com.
String accessKeyId = "<yourAccessKeyId>";
String accessKeySecret = "<yourAccessKeySecret>";

// Create an OSSClient instance.
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);

// Information about a bucket includes the region (Region or Location), creation date (CreationDate), owner (Owner), and ACL (Grants) of the bucket.
BucketInfo info = ossClient.getBucketInfo("<yourBucketName>");
// Query the region.
info.getBucket().getLocation();
// Query the creation date.
info.getBucket().getCreationDate();
// Query the owner information.
info.getBucket().getOwner();
// Query the ACL information.
info.getGrants();
// Query the type of redundant storage.
info.getDataRedundancyType();

// Shut down the OSSClient instance.
ossClient.shutdown();            

For more information about how to query information about a bucket, see GetBucketInfo.