Static Website

Last updated: 2020-08-31 16:26:44

    Overview

    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

    SDK API References

    For the parameters and method descriptions of all the APIs in the SDK, see Api Documentation.

    Setting a Static Website Configuration

    API description

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

    Sample code

    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.

    Querying a Static Website Configuration

    API description

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

    Sample code

    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.

    Deleting a Static Website Configuration

    API description

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

    Sample code

    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?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback
    Help