Custom Domain

Last updated: 2023-09-20 13:09:01

Feature Overview

This document provides an overview of APIs and SDK code samples for custom domains.
API
Operation
Description
PUT Bucket domain
Setting a Custom Endpoint
Sets a custom endpoint for a bucket
GET Bucket domain
Querying a custom endpoint
Queries the custom endpoint of a bucket

SDK API References

For detailed parameters and method descriptions of all SDK interfaces, please refer to SDK API.

Setting a Custom Endpoint

Note

This API is used to configure a custom endpoint for a bucket.

Sample code

try
{
// Bucket name, the format must be bucketname-APPID, for obtaining APPID refer to https://console.cloud.tencent.com/developer
string bucket = "examplebucket-1250000000";

DomainConfiguration domain = new DomainConfiguration();
domain.rule = new DomainConfiguration.DomainRule();
domain.rule.Name = "www.qq.com";
domain.rule.Status = "ENABLED";
domain.rule.Type = "WEBSITE";

PutBucketDomainRequest request = new PutBucketDomainRequest(bucket, domain);
// Execute the request
PutBucketDomainResult result = cosXml.PutBucketDomain(request);

//Request successful
Console.WriteLine(result.GetResultInfo());
}
catch (COSXML.CosException.CosClientException clientEx)
{
//Request failed
Console.WriteLine("CosClientException: " + clientEx);
}
catch (COSXML.CosException.CosServerException serverEx)
{
//Request failed
Console.WriteLine("CosServerException: " + serverEx.GetInfo());
}
Note
For the complete sample, go to GitHub.

Error codes

The following describes some common errors that may occur when making requests using this API.
Status code
Note
HTTP 409 Conflict
The endpoint record already exists, and forced overwrite is not specified in the request; OR the endpoint record does not exist, and forced overwrite is specified in the request
HTTP 451 Unavailable For Legal Reasons
The domain does not have an ICP filing in the Chinese mainland

Querying a custom endpoint

Note

This API is used to query the custom endpoint of a bucket.

Sample code

try
{
// Bucket name, the format must be bucketname-APPID, for obtaining APPID refer to https://console.cloud.tencent.com/developer
string bucket = "examplebucket-1250000000";
GetBucketDomainRequest request = new GetBucketDomainRequest(bucket);
// Execute the request
GetBucketDomainResult result = cosXml.GetBucketDomain(request);

//Request successful
Console.WriteLine(result.domainConfiguration);
}
catch (COSXML.CosException.CosClientException clientEx)
{
//Request failed
Console.WriteLine("CosClientException: " + clientEx);
}
catch (COSXML.CosException.CosServerException serverEx)
{
//Request failed
Console.WriteLine("CosServerException: " + serverEx.GetInfo());
}
Note
For the complete sample, go to GitHub.

Response parameter description

Parameter name
Description
Local Disk Types
x-cos-domain-txt-verification
Domain verification information, this field is an MD5 checksum value, the original string format is: cos[Region][BucketName-APPID][BucketCreateTime], where Region is the location of the storage bucket, and BucketCreateTime is the storage bucket's GMT creation time.
String