tencent cloud

All product documents
Cloud Object Storage
Static Website
Last updated: 2024-02-02 14:36:36
Static Website
Last updated: 2024-02-02 14:36:36

Overview

This document provides an overview of APIs and SDK code samples related to static website.
API
Operation
Description
Setting a static website configuration
Configures a static website for a bucket
Querying a static website configuration
Queries the static website configuration of a bucket
Deleting a static website configuration
Deletes the static website configuration of a bucket

Setting Static Website Configuration

Description

This API is used to configure a static website for a bucket.

Sample code

try
{
// Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.tencentcloud.com/developer.
string bucket = "examplebucket-1250000000";
PutBucketWebsiteRequest putRequest = new PutBucketWebsiteRequest(bucket);
putRequest.SetIndexDocument("index.html");
putRequest.SetErrorDocument("eroror.html");
putRequest.SetRedirectAllRequestTo("index.html");
PutBucketWebsiteResult putResult = cosXml.PutBucketWebsite(putRequest);

// Request succeeded
Console.WriteLine(putResult.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 more samples, please visit GitHub.

Querying Static Website Configuration

Description

This API is used to query the static website configuration associated with a bucket.

Sample code

try
{
// Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.tencentcloud.com/developer.
string bucket = "examplebucket-1250000000";
GetBucketWebsiteRequest request = new GetBucketWebsiteRequest(bucket);
// Execute the request
GetBucketWebsiteResult result = cosXml.GetBucketWebsite(request);

// Request succeeded
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 more samples, please visit GitHub.

Deleting Static Website Configuration

Description

This API is used to delete the static website configuration of a bucket.

Sample code

try
{
// Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.tencentcloud.com/developer.
string bucket = "examplebucket-1250000000";
DeleteBucketWebsiteRequest request = new DeleteBucketWebsiteRequest(bucket);
// Execute the request
DeleteBucketWebsiteResult result = cosXml.DeleteBucketWebsite(request);

// Request succeeded
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 more samples, please visit GitHub.
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