A bucket is a container for objects stored in OSS. Every object is contained in a bucket. This topic describes how to determine whether a bucket exists.

#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.*/

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

    /*Determine whether the bucket exists.*/
    auto outcome = client.DoesBucketExist(BucketName);

    if (outcome) {    
        std::cout << " The Bucket exists" << std::endl;
    else {
        std::cout << "The Bucket does not exist" << std::endl;

    /*Release network resources.*/
    return 0;