All Products
Search
Document Center

Object Storage Service:Get bucket information (Android SDK)

Last Updated:Mar 20, 2026

Use the OSS Android SDK to retrieve metadata about a bucket.

Prerequisites

Before you begin, ensure that you have:

  • An initialized OSSClient instance. See Initialization for supported methods, including custom domain name and Security Token Service (STS).

Get bucket information

Call asyncGetBucketInfo with the bucket name. On failure, the callback receives either a client exception (for network errors) or a service exception (for API errors).

For the complete runnable example, see the GitHub sample.

GetBucketInfoRequest request = new GetBucketInfoRequest("bucketName");

OSSAsyncTask task = oss.asyncGetBucketInfo(request, new OSSCompletedCallback<GetBucketInfoRequest, GetBucketInfoResult>() {
    @Override
    public void onSuccess(GetBucketInfoRequest request, GetBucketInfoResult result) {
        Log.i("GetBucketInfo", "code: " + result.getStatusCode());
    }

    @Override
    public void onFailure(GetBucketInfoRequest request, ClientException clientException, ServiceException serviceException) {
        if (clientException != null) {
            // Network or client-side error (e.g., connection timeout)
            clientException.printStackTrace();
        }
        if (serviceException != null) {
            Log.e("ErrorCode", serviceException.getErrorCode());
            Log.e("RequestId", serviceException.getRequestId());
            Log.e("HostId", serviceException.getHostId());
            Log.e("RawMessage", serviceException.getRawMessage());
        }
    }
});

What's next

  • GetBucketInfo — underlying API reference with the full list of returned fields

  • Initialization — how to initialize an OSSClient instance for Android