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:

GetBucketInfoRequest request = new GetBucketInfoRequest("<bucketName>");

// Query the information about the bucket.
OSSAsyncTask task = oss.asyncGetBucketInfo(request, new OSSCompletedCallback<GetBucketInfoRequest, GetBucketInfoResult>() {
    @Override
    public void onSuccess(GetBucketInfoRequest request, GetBucketInfoResult result) {
        OSSLog.logInfo("code: " + result.getStatusCode());
    }

    @Override
    public void onFailure(GetBucketInfoRequest request, ClientException clientException, ServiceException serviceException) {
        // Handle request exceptions.
        if (clientException ! = null) {
            // Handle client exceptions, such as network exceptions.
            clientException.printStackTrace();
        }
        if (serviceException ! = null) {
            // Handle service exceptions.
            Log.e("ErrorCode", serviceException.getErrorCode());
            Log.e("RequestId", serviceException.getRequestId());
            Log.e("HostId", serviceException.getHostId());
            Log.e("RawMessage", serviceException.getRawMessage());
        }
    }
});

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