Feature Overview
This document describes how to use a non-default domain to request COS.
Default CDN Acceleration Domain Name
Note
To use a default CDN acceleration endpoint to access COS, you need to enable the default CDN acceleration endpoint feature for your bucket in the COS console. For operation details, see Enabling Default CDN Acceleration Domain Names.
Sample Request
qcloud_cos::CosConfig config("./config.json");qcloud_cos::CosAPI cos(config);// Replaceexamplebucket-1250000000with your bucket name.CosSysConfig::SetDomainSameToHost(true);CosSysConfig::SetDestDomain("examplebucket-1250000000.file.myqcloud.com");
Or you can modify
config.json as follows:"IsDomainSameToHost":true,"DestDomain":"examplebucket-1250000000.file.myqcloud.com",
Custom CDN acceleration domain name
Note
To use a custom CDN acceleration domain name to access COS, you need to enable the custom CDN acceleration domain name feature for your bucket in the COS console. For operation details, see Enabling Custom CDN Accelerated Domain Name.
Sample Request
qcloud_cos::CosConfig config("./config.json");qcloud_cos::CosAPI cos(config);// Replacemycdndomain.comwith your CDN domain name.CosSysConfig::SetDomainSameToHost(true);CosSysConfig::SetDestDomain("mycdndomain.com");
Or you can modify
config.json as follows:"IsDomainSameToHost":true,"DestDomain":"emycdndomain.com",
Custom origin domain name
Note
To use a custom origin server domain name to access COS, you need to enable the custom origin server domain name feature for your bucket in the COS console. For operation details, see Enabling Custom Origin Server Domains.
Sample Request
qcloud_cos::CosConfig config("./config.json");qcloud_cos::CosAPI cos(config);// Replacemydomain.comwith your custom domain name.CosSysConfig::SetDomainSameToHost(true);CosSysConfig::SetDestDomain("mydomain.com");
Or you can modify
config.json as follows:"IsDomainSameToHost":true,"DestDomain":"mydomain.com",
Global acceleration domain name
Note
To use a global acceleration domain name to access COS, you need to enable the global acceleration domain name feature for your bucket in the COS console. For operation details, see Enabling Global Acceleration.
Sample Request
qcloud_cos::CosConfig config("./config.json");config.SetRegion("accelerate")qcloud_cos::CosAPI cos(config);
Or you can modify
config.json as follows:"Region":"accelerate",