Get bucket information (Android SDK)
Updated at:
A bucket is a container used to store objects in Object Storage Service (OSS). This topic describes how to query information about a bucket.
Usage notes
-
Before you run the sample code in this topic, you must create an OSSClient instance by using methods such as using a custom domain name or Security Token Service (STS). For more information, see Initialization (Android SDK).
Examples
The following code shows how to retrieve information about a bucket:
GetBucketInfoRequest request = new GetBucketInfoRequest("bucketName");
// Get information about the bucket.
OSSAsyncTask task = oss.asyncGetBucketInfo(request, new OSSCompletedCallback<GetBucketInfoRequest, GetBucketInfoResult>() {
@Override
public void onSuccess(GetBucketInfoRequest request, GetBucketInfoResult result) {
Log.i("i", "code: " + result.getStatusCode());
}
@Override
public void onFailure(GetBucketInfoRequest request, ClientException clientException, ServiceException serviceException) {
// Request exception.
if (clientException != null) {
// Client exception, such as a network exception.
clientException.printStackTrace();
}
if (serviceException != null) {
// Service exception.
Log.e("ErrorCode", serviceException.getErrorCode());
Log.e("RequestId", serviceException.getRequestId());
Log.e("HostId", serviceException.getHostId());
Log.e("RawMessage", serviceException.getRawMessage());
}
}
});
References
-
For the complete sample code to retrieve bucket information, see the GitHub example.
-
For more information about the API operation to retrieve bucket information, see GetBucketInfo.
-
For more information, see How to initialize an OSSClient instance for Android.
Is this page helpful?