tencent cloud

All product documents
Cloud Object Storage
DocumentationCloud Object StorageSDK DocumentationGo SDKSetting Access Domain Names (CDN/Global Acceleration)
Setting Access Domain Names (CDN/Global Acceleration)
Last updated: 2024-02-02 15:51:37
Setting Access Domain Names (CDN/Global Acceleration)
Last updated: 2024-02-02 15:51:37

Overview

This document describes how to use a non-default domain to request COS.

Setting the default COS domain

Sample request

// Replace examplebucket-1250000000 and COS_REGION with the actual information.
u, _ := url.Parse("https://examplebucket-1250000000.cos.COS_REGION.myqcloud.com")
// The following calls the `Get Service` API. By default, all regions (service.cos.myqcloud.com) will be queried.
su, _ := url.Parse("https://cos.COS_REGION.myqcloud.com")
b := &cos.BaseURL{BucketURL: u, ServiceURL: su}
// 1. Permanent key
client := cos.NewClient(b, &http.Client{
Transport: &cos.AuthorizationTransport{
SecretID: "SECRETID",
SecretKey: "SECRETKEY",
},
})

Default CDN acceleration domain name

Description

After enabling a default CDN acceleration domain name for a bucket through the COS console, you can set the domain name in the SDK code for acceleration. For more information, please see Enabling Default CDN Acceleration Domain Names.

Sample request

// Replace examplebucket-1250000000 with the actual information.
u, _ := url.Parse("https://examplebucket-1250000000.file.myqcloud.com")
b := &cos.BaseURL{BucketURL: u}
// Use a CDN acceleration domain. COS verification information does not need to be sent.
client := cos.NewClient(b, &http.Client{})

Custom CDN acceleration domain name

Description

After setting a custom CDN acceleration domain name for a bucket through the COS console, you can set the domain name in the SDK code to implement acceleration for the custom domain. For more information, please see Enabling Custom Accelerated Domain Name.

Sample request

// Set the custom CDN acceleration domain.
u, _ := url.Parse("https://xxx.xxx.com")
b := &cos.BaseURL{BucketURL: u}
// Use a CDN acceleration domain. COS verification information does not need to be sent.
client := cos.NewClient(b, &http.Client{})

Custom origin server domain name

Sample request

// Custom origin server domain
u, _ := url.Parse("https://xxx.xxx.com")
b := &cos.BaseURL{BucketURL: u}
client := cos.NewClient(b, &http.Client{
Transport: &cos.AuthorizationTransport{
SecretID: "SECRETID",
SecretKey: "SECRETKEY",
},
})

Global acceleration endpoint

Sample request

// Global acceleration domain
// Replace examplebucket-1250000000 with the actual information.
u, _ := url.Parse("https://examplebucket-1250000000.cos.accelerate.myqcloud.com")
b := &cos.BaseURL{BucketURL: u}
client := cos.NewClient(b, &http.Client{
Transport: &cos.AuthorizationTransport{
SecretID: "SECRETID",
SecretKey: "SECRETKEY",
},
})
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 available.

7x24 Phone Support
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