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.

#include <alibabacloud/oss/OssClient.h>
using namespace AlibabaCloud::OSS;

int main(void)
{
    /*Initialize the OSS account information.*/
    std::string AccessKeyId = "yourAccessKeyId";
    std::string AccessKeySecret = "yourAccessKeySecret";
    std::string Endpoint = "yourEndpoint";
    std::string BucketName = "yourBucketName";

    /*Initialize network resources.*/
    InitializeSdk();

    ClientConfiguration conf;
    OssClient client(Endpoint, AccessKeyId, AccessKeySecret, conf);

    /*Query the bucket information.*/
    GetBucketInfoRequest request(BucketName);
    auto outcome = client.GetBucketInfo(request);

    /*View the type of redundant storage of the bucket.*/
    if (outcome.isSuccess()) {
        std::cout << "GetBucketInfo success, DataRedundancyType:" << outcome.result().DataRedundancyType() << std::endl;
    }
    else {
        /*Handle exceptions.*/
        std::cout << "GetBucketInfo fail" <<
        ",code:" << outcome.error().Code() <<
        ",message:" << outcome.error().Message() <<
        ",requestId:" << outcome.error().RequestId() << std::endl;
        ShutdownSdk();
        return -1;
    }

    /*Release network resources.*/
    ShutdownSdk();
    return 0;
}

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