Release Notes
Announcements
Function Name | Description | Example code |
Object Access URL | Implementing the feature of generating object access URLs |
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;}
std::string CosAPI::GetObjectUrl(const std::string& bucket,const std::string& object, bool https,const std::string& region)
void GetObjectUrlDemo(qcloud_cos::CosAPI& cos) {std::string object_name = "test.txt";bool is_https = true; // Whether it is httpsstd::string object_url = cos.GetObjectUrl(bucket_name, object_name, is_https);std::cout << "=======================GetObjectUrl=========================" << std::endl;std::cout << "object url=[" << object_url << "]" << std::endl;std::cout << "============================================================" << std::endl;}
Parameter Name | Description | Type |
bucket_name | The naming format of a Bucket is BucketName-APPID. For details, see Naming Conventions | string |
object_name | An object key is a unique identifier for an object in a bucket. For example, in the object access domain name examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com/doc/picture.jpg The object key is doc/picture.jpg. For details, see Object Key | string |
is_https | Whether it is https, defaults to false. | bool |
region | The bucket region can be omitted and defaults to the region in the CosAPI instance. | string |
Esta página foi útil?
Você também pode entrar em contato com a Equipe de vendas ou Enviar um tíquete em caso de ajuda.
comentários