Release Notes
Announcements
cos:HeadBucket. For more authorization, see business APIs that support CAM.Function Name | Description | Example code |
Check Bucket Existence | Check Bucket Existence |
qcloud_cos::CosAPI InitCosAPI() {uint64_t appid = 12500000000;std::string region = "ap-guangzhou";// Region of the bucket, see https://www.tencentcloud.com/document/product/436/62?from_cn_redirect=1std::string secret_id = "************************************"; // User's SecretId. It is recommended to use sub-account keys, with authorization following the least privilege principle to mitigate usage risks. For information on how to obtain sub-account keys, see https://www.tencentcloud.com/document/product/598/37140?from_cn_redirect=1std::string secret_key = "************************************"; // User's SecretKey. It is recommended to use sub-account keys, with authorization following the least privilege principle to mitigate usage risks. For information on how to obtain sub-account keys, see https://www.tencentcloud.com/document/product/598/37140?from_cn_redirect=1qcloud_cos::CosConfig config(appid, secret_id, secret_key, region);qcloud_cos::CosAPI cos_tmp(config);return cos_tmp;}
qcloud_cos::CosAPI InitCosAPI() {// You need to have obtained the temporary key results: tmp_secret_id, tmp_secret_key,// For generating temporary keys, see https://www.tencentcloud.com/document/product/436/14048?from_cn_redirect=1#cos-sts-sdkuint64_t appid = 12500000000;std::string region = "ap-guangzhou";std::string tmp_secret_id = "************************************";std::string tmp_secret_key = "************************************";std::string tmp_token = "token";qcloud_cos::CosConfig config(appid, tmp_secret_id, tmp_secret_key, region);config.SetTmpToken(tmp_token);qcloud_cos::CosAPI cos_tmp(config);return cos_tmp;}
bool CosAPI::IsBucketExist(const std::string& bucket_name)
void IsBucketExist(qcloud_cos::CosAPI& cos) {std::cout << "===================IsBucketExist====================="<< std::endl;std::cout << (cos.IsBucketExist("abcdefg") ? "true" : "false") << std::endl;std::cout << (cos.IsBucketExist(bucket_name) ? "true" : "false") << std::endl;std::cout<< "===================================================================="<< std::endl;}
Parameter Name | Description | Type |
bucket_name | Bucket Name | string |
Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
masukan