tencent cloud

$0 14-Day TrialExperience EdgeOne for acceleration and security protection!

文档反馈

对象存储

对象访问 URL

最后更新时间:2024-01-04 18:00:58

简介

本文档提供获取对象访问 URL 的代码示例。

获取对象访问 URL

方法原型

std::string GetObjectUrl(const std::string& bucket, const std::string& object, bool https = true, const std::string& region);

请求示例

qcloud_cos::CosConfig config("./config.json");
qcloud_cos::CosAPI cos(config);

std::string bucket_name = "examplebucket-1250000000"; // 替换为用户的存储桶名,由bucketname-appid 组成,appid必须填入,可以在COS控制台查看存储桶名称:https://console.tencentcloud.com/cos5/bucket
std::string object_name = "exampleobject";
//获取对象https url,region为config.json中配置的地域
cos.GetObjectUrl(bucket_name, object_name);
//获取对象http url,region为config.json中配置的地域
cos.GetObjectUrl(bucket_name, object_name, false);
//获取对象https url, region为ap-shanghai
std::string object_url = cos.GetObjectUrl(bucket_name, object_name, true, "ap-shanghai");

参数说明

参数
参数描述
类型
是否必填
bucket
存储桶名
string
object
对象名
string
https
是否使用 https
bool
region
地域名
string

返回结果说明

该方法返回值为对象访问的 URL。

产品类别

文档章节

对象访问 URL

联系我们

联系我们,为您的业务提供专属服务。

技术支持

如果你想寻求进一步的帮助,通过工单与我们进行联络。我们提供7x24的工单服务。

7x24 电话支持
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon