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

Setting Access Domain Names (CDN/Global Acceleration)

Last updated: 2023-09-13 11:25:28

Feature Overview

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

Parameter description

You can use the initialization parameters below to control the request domain:
Parameter
ParameterDescription
Local Disk Types
Required
domain
Custom request domain when calling APIs for bucket and object operations. You can use a template, such as "{$Bucket}.cos.{$Region}.myqcloud.com", which will replace the Bucket and Region values with those passed in the parameters when calling the API.
String
Not required
schema
Protocol used when sending requests. Options: https and http. The default is http if the current page is http, otherwise, https is used.
String
Not required

Default CDN Acceleration Domain Name

The sample code below shows how to access a COS service using a default CDN acceleration domain name.
$bucket = "examplebucket-1250000000";

$cosClient = new Qcloud\Cos\Client(
array(
'domain' => $bucket . '.file.myqcloud.com', // Default acceleration domain name
'schema' => 'https', //Protocol header, default is http
'credentials'=> array(
'secretId' => $secretId,
'secretKey' => $secretKey
)
)
);

Custom CDN acceleration domain name

The sample code below shows how to access a COS service using a custom CDN acceleration domain name.
$cosClient = new Qcloud\Cos\Client(
array(
'domain' => 'example-cdn-domain.com', // Default acceleration domain
'schema' => 'https', //Protocol header, default is http
'credentials'=> array(
'secretId' => $secretId,
'secretKey' => $secretKey
)
)
);

Custom origin domain name

For more information, see Enabling Custom Origin Domain.
The sample code below shows how to access a COS service using a custom origin server domain name.
$cosClient = new Qcloud\Cos\Client(
array(
'domain' => 'example-cos-domain.com', // Default acceleration domain name
'schema' => 'https', //Protocol header, default is http
'credentials'=> array(
'secretId' => $secretId,
'secretKey' => $secretKey
)
)
);

Global acceleration domain name

For more information on global acceleration, see Overview.
The sample code below shows how to access a COS service using a global acceleration endpoint.
// Change {$bucket}.cos.{$region}.myqcloud.com/key to the one below:
//{$bucket}.cos.accelerate.myqcloud.com/key
$cosClient = new Qcloud\Cos\Client(
array(
'schema' => 'https', //Protocol header, default is http
'credentials'=> array(
'secretId' => $secretId,
'secretKey' => $secretKey
),
'allow_accelerate' => true // Set to true to use GAAP domain name for requests
)
);