This document provides an overview of APIs and SDK code samples related to static websites.
API | Operation | Description |
---|---|---|
PUT Bucket website | Setting a static website configuration | Configures a static website for a bucket |
GET Bucket website | Querying a static website configuration | Queries the static website configuration of a bucket |
DELETE Bucket website | Deleting a static website configuration | Deletes the static website configuration of a bucket |
For the parameters and method descriptions of all the APIs in the SDK, see Api Documentation.
This API is used to configure a static website for a bucket.
try
{
String bucket = "examplebucket-1250000000"; // Format: BucketName-APPID
PutBucketWebsiteRequest putRequest = new PutBucketWebsiteRequest(bucket);
putRequest.SetIndexDocument("index.html");
putRequest.SetErrorDocument("eroror.html");
putRequest.SetRedirectAllRequestTo("index.html");
PutBucketWebsiteResult putResult = cosXml.PutBucketWebsite(putRequest);
// Request successful
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.
This API is used to query the static website configuration associated with a bucket.
try
{
String bucket = "examplebucket-1250000000"; // Format: BucketName-APPID
DeleteBucketTaggingRequest request = new DeleteBucketTaggingRequest(bucket);
// Execute the request
DeleteBucketTaggingResult result = cosXml.DeleteBucketTagging(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 more samples, please visit GitHub.
This API is used to delete the static website configuration of a bucket.
try
{
String bucket = "examplebucket-1250000000"; // Format: BucketName-APPID
DeleteBucketTaggingRequest request = new DeleteBucketTaggingRequest(bucket);
// Execute the request
DeleteBucketTaggingResult result = cosXml.DeleteBucketTagging(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 more samples, please visit GitHub.
Was this page helpful?