API | Operation | Description |
Setting bucket referer configuration | Sets a bucket referer allowlist or blocklist | |
Querying bucket referer configuration | Queries a bucket referer allowlist or blocklist |
CosResult PutBucketReferer(const PutBucketRefererReq& request, PutBucketRefererResp* response);
qcloud_cos::CosConfig config("./config.json");qcloud_cos::CosAPI cos(config);std::string bucket_name = "examplebucket-1250000000"; // Replaced with the bucket nameqcloud_cos::PutBucketRefererReq req(bucket_name);qcloud_cos::PutBucketRefererResp resp;// Construct the request as neededreq.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()) {// Request succeeded} else {// Request failed. You can call the CosResult member functions to output the error information, such as requestID.}
Parameter | Description | Type | Required |
req | Request of the PutBucketReferer operation | PutBucketRefererReq | Yes |
resp | Response of the PutBucketReferer operation | PutBucketRefererResp | Yes |
CosResult GetBucketReferer(const GetBucketRefererReq& request, GetBucketRefererResp* response);
qcloud_cos::CosConfig config("./config.json");qcloud_cos::CosAPI cos(config);std::string bucket_name = "examplebucket-1250000000"; // Replaced with the bucket nameqcloud_cos::GetBucketRefererReq req(bucket_name);qcloud_cos::GetBucketRefererResp resp;qcloud_cos::CosResult result = cos.GetBucketReferer(req, &resp);if (result.IsSucc()) {// Request succeeded. Obtain the referer configuration.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 {// Request failed. You can call the CosResult member functions to output the error information, such as requestID.}
Parameter | Description | Type | Required |
req | Request of the GetBucketReferer operation | GetBucketRefererReq | Yes |
resp | Response of the GetBucketReferer operation | GetBucketRefererResp | Yes |
Apakah halaman ini membantu?