API | 操作名 | 操作描述 |
设置存储桶 Referer | 设置存储桶 Referer 白名单或者黑名单 | |
查询存储桶 Referer | 查询存储桶 Referer 白名单或者黑名单 |
CosResult PutBucketReferer(const PutBucketRefererReq& request, PutBucketRefererResp* response);
qcloud_cos::CosConfig config("./config.json");qcloud_cos::CosAPI cos(config);std::string bucket_name = "examplebucket-1250000000"; // 替换为用户的存储桶名qcloud_cos::PutBucketRefererReq req(bucket_name);qcloud_cos::PutBucketRefererResp resp;// 根据实际情况构造请求req.SetStatus("Enabled");req.SetRefererType("White-List");req.AddDomain("test1.com");req.AddDomain("test2.com");qcloud_cos::CosResult result = cos.PutBucketReferer(req, &resp);if (result.IsSucc()) {// 请求成功} else {// 请求失败,调用 CosResult 的成员函数输出错误信息,例如 requestID 等}
参数 | 参数描述 | 类型 | 是否必填 |
req | PutBucketReferer操作的请求 | PutBucketRefererReq | 是 |
resp | PutBucketReferer操作的响应 | PutBucketRefererResp | 是 |
CosResult GetBucketReferer(const GetBucketRefererReq& request, GetBucketRefererResp* response);
qcloud_cos::CosConfig config("./config.json");qcloud_cos::CosAPI cos(config);std::string bucket_name = "examplebucket-1250000000"; // 替换为用户的存储桶名qcloud_cos::GetBucketRefererReq req(bucket_name);qcloud_cos::GetBucketRefererResp resp;qcloud_cos::CosResult result = cos.GetBucketReferer(req, &resp);if (result.IsSucc()) {// 请求成功,获取referer配置std::cout << "Status:" << resp.GetStatus() << std::endl;std::cout << "RefererType:" << resp.GetRefererType() << std::endl;for (auto& domain : resp.GetDomainList()) {std::cout << "Domain:" << domain << std::endl;}std::cout << "EmptyReferConfiguration:" << resp.GetEmptyReferConf() << std::endl;} else {// 请求失败,调用 CosResult 的成员函数输出错误信息,例如 requestID 等}
参数 | 参数描述 | 类型 | 是否必填 |
req | GetBucketReferer操作的请求 | GetBucketRefererReq | 是 |
resp | GetBucketReferer操作的响应 | GetBucketRefererResp | 是 |
本页内容是否解决了您的问题?