Custom Domain

Last updated: 2020-03-20 09:51:52

PDF

Note

This document provides an overview of API for custom domain names and sample SDK code.

API Operation name pedagogical operation
PUT Bucket domain Set up a custom domain name Set Bucket's custom domain name information
GET Bucket domain Query custom domain name Query Bucket's custom domain name information

Set up a custom domain name

Function description

PUT Bucket domain is used to configure a custom domain name for Bucket.

Method prototype

public Guzzle\Service\Resource\Model PutBucketDomain(array $args = array());

Request Sample

try {
    $result = $cosClient->putBucketDomain(array( 
        'Bucket' => 'examplebucket-1250000000', 
        'DomainRules' => array( 
            array( 
                'Name' => 'www.qq.com', 
                'Status' => 'ENABLED', 
                'Type' => 'REST', 
                'ForcedReplacement' => 'CNAME', 
            ),  
            // ... repeated 
        ),  
    )); 
    print_r($result);
} catch (\Exception $e) {
    echo($e);
}

Parameter description

Parameter name Description Type
Bucket Set the custom domain name Bucket in BucketName-APPID format. For more information, please see Naming convention String
Name Custom Domain String
Status Domain name Activate status. Available values include ENABLED and DISABLED String
Type The type of real server bound. Available values include REST and WEBSITE. String
ForcedReplacement Forced overwrite of existing configurations. Available values include CNAME and TXT String

Returns the error code description

Some common special errors that may occur in this request are as follows:

Status Code Description
HTTP 409 Conflict The domain name record already exists and no mandatory overwrite is set in the request. Or the domain name record does not exist and a forced overwrite is set in the request
HTTP 451 Unavailable For Legal Reasons The domain name is a domain name within China, and there is no ICP filing.

Query custom domain name

Function description

GET Bucket domain is used to query Bucket's custom domain name information.

Method prototype

public Guzzle\Service\Resource\Model GetBucketDomain(array $args = array());

Request Sample

try {
    $result = $cosClient->getBucketDomain(array( 
        'Bucket' => 'examplebucket-1250000000', 
    )); 
    print_r($result);
} catch (\Exception $e) {
    echo($e);
}

Parameter description

Parameter name Description Type
Bucket Query the Bucket of the custom domain name in BucketName-APPID format. For more information, please see Naming convention String

Return an example of the result

GuzzleHttp\Command\Result Object
(
    [DomainRules] => Array
        (
            [0] => Array
                (
                    [Status] => ENABLED
                    [Name] => www.qq.com
                    [Type] => REST
                )

        )
    [DomainTxtVerification] => tencent-cloud-cos-verification=9d2258433b1f38c7dd4b29fe272d2128
)

Return result description

Parameter name Description Type
Name Custom Domain String
Status Domain name Activate status. Available values include ENABLED and DISABLED String
Type The type of real server bound. Available values include REST and WEBSITE. String
ForcedReplacement Forced overwrite of existing configurations. Available values include CNAME and TXT String
DomainTXTVerification Domain name verification information. This field is a MD5 check value. The original string format is:
cos[Region][BucketName-APPID][BucketCreateTime] Where Region is the region where Bucket is located, and BucketCreateTime is the creation time of Bucket GMT
String