Help & Documentation>Cloud Object Storage>SDK Documentation>C SDK>Setting Access Domain Names (CDN/Global Acceleration)

Setting Access Domain Names (CDN/Global Acceleration)

Last updated: 2023-09-13 11:24:54

Feature Overview

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

Default CDN Acceleration Domain Name

Note

After enabling the default CDN acceleration domain for the bucket in the COS Console, you can set the corresponding domain in the SDK code to implement the default acceleration feature. For information on how to enable the default acceleration domain, please refer to Enabling the Default CDN Acceleration Domain.

Sample Request

cos_pool_t *p = NULL;
cos_request_options_t *options = NULL;
cos_pool_create(&p, NULL);
options = cos_request_options_create(p);
options->config = cos_config_create(options->pool);
// The request domain format is <bucketname-appid>.file.myqcloud.com
cos_str_set(&options->config->endpoint, "<bucketname-appid>.file.myqcloud.com");

Description

Parameter name
Description
Local Disk Types
endpoint
Set the domain suffix to use the CDN acceleration domain name
String

Custom CDN acceleration domain name

Note

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 for acceleration. For more information, see Enabling Custom Accelerated Domain Name.

Sample Request

cos_pool_t *p = NULL;
cos_request_options_t *options = NULL;
cos_pool_create(&p, NULL);
options = cos_request_options_create(p);
options->config = cos_config_create(options->pool);
// Set the requested endpoint to your.domain.com
cos_str_set(&options->config->endpoint, "your.domain.com"); // Custom CDN domain
// Set is_cname to 1
options->config->is_cname = 1

Description

Parameter name
Description
Local Disk Types
endpoint
Set the domain suffix to use a custom CDN endpoint
String
is_cname
Set this parameter to 1 to use the custom CDN endpoint mode
Int

Custom origin domain name

Note

After setting a custom origin server domain for a bucket through the COS console, you can set the domain name in the SDK code to access COS resources. For more information, see Enabling Custom Origin Server Domains.

Sample code

cos_pool_t *p = NULL;
cos_request_options_t *options = NULL;
cos_pool_create(&p, NULL);
options = cos_request_options_create(p);
options->config = cos_config_create(options->pool);
// Set the requested endpoint to your.domain.com
cos_str_set(&options->config->endpoint, "your.domain.com"); // Custom endpoint
// Set is_cname to 1
options->config->is_cname = 1

Description

Parameter name
Description
Local Disk Types
endpoint
Set the domain suffix to use a custom origin server endpoint
String
is_cname
Set this parameter to 1 to use the custom origin server endpoint mode
Int

Global acceleration domain name

Note

After enabling a global acceleration domain name for a bucket through the COS console, you can set the domain name in the SDK code for global acceleration. For more information, see Overview.

Sample code

cos_pool_t *p = NULL;
cos_request_options_t *options = NULL;
cos_pool_create(&p, NULL);
options = cos_request_options_create(p);
options->config = cos_config_create(options->pool);
// Set the requested endpoint to cos.accelerate.myqcloud.com
cos_str_set(&options->config->endpoint, "cos.accelerate.myqcloud.com");

Description

Parameter name
Description
Local Disk Types
endpoint
Set the domain suffix to use a global acceleration domain name.
String