Overview
This document describes how to request the COS service using a non-default endpoint.
SDK API References
For the parameters and method descriptions of all the APIs in the SDK, see SDK API Reference. Default CDN acceleration domain name
The sample code below shows how to access a COS service using a default CDN acceleration domain name.
Sample code
String region = "ap-beijing";
String cdnDomain = "examplebucket-1250000000.file.myqcloud.com";
CosXmlServiceConfig cosXmlServiceConfig = new CosXmlServiceConfig.Builder()
.isHttps(true)
.setRegion(region)
.setDebuggable(false)
.setHostFormat(cdnDomain)
.addHeader("Host", cdnDomain)
.builder();
CosXmlService cosXmlService = new CosXmlService(context, cosXmlServiceConfig);
Note:
For more samples, please visit GitHub. Custom CDN acceleration domain name
The sample code below shows how to access a COS service using a custom CDN acceleration domain name.
Sample code
String region = "ap-beijing";
String cdnCustomDomain = "exampledomain.com";
CosXmlServiceConfig cosXmlServiceConfig = new CosXmlServiceConfig.Builder()
.isHttps(true)
.setRegion(region)
.setDebuggable(false)
.setHostFormat(cdnCustomDomain)
.addHeader("Host", cdnCustomDomain)
.builder();
CosXmlService cosXmlService = new CosXmlService(context, cosXmlServiceConfig);
Note:
For more samples, please visit GitHub. Custom origin server domain name
The sample code below shows how to access a COS service using a custom origin server domain name.
Sample code
String region = "ap-beijing";
String customDomain = "exampledomain.com";
CosXmlServiceConfig cosXmlServiceConfig = new CosXmlServiceConfig.Builder()
.isHttps(true)
.setRegion(region)
.setDebuggable(false)
.setHostFormat(customDomain)
.builder();
CosXmlService cosXmlService = new CosXmlService(context, cosXmlServiceConfig,
credentialProvider);
Note:
For more samples, please visit GitHub. Global acceleration endpoint
For more information on global acceleration, see Overview. The sample code below shows how to access a COS service using a global acceleration endpoint.
Sample code
String region = "ap-beijing";
CosXmlServiceConfig cosXmlServiceConfig = new CosXmlServiceConfig.Builder()
.isHttps(true)
.setRegion(region)
.setDebuggable(false)
.setAccelerate(true)
.builder();
CosXmlService cosXmlService = new CosXmlService(context, cosXmlServiceConfig,
credentialProvider);
Note:
For more samples, please visit GitHub.
Was this page helpful?