简介
本文档提供关于静态网站的 API 概览以及 SDK 示例代码。
API | 操作名 | 操作描述 |
设置静态网站 | 设置存储桶的静态网站配置 | |
查询静态网站配置 | 查询存储桶的静态网站配置 | |
删除静态网站配置 | 删除存储桶的静态网站配置 |
设置静态网站
功能说明
PUT Bucket website 用于为存储桶配置静态网站。
示例代码
try{// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.cloud.tencent.com/developerstring 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);//请求成功Console.WriteLine(putResult.GetResultInfo());}catch (COSXML.CosException.CosClientException clientEx){//请求失败Console.WriteLine("CosClientException: " + clientEx);}catch (COSXML.CosException.CosServerException serverEx){//请求失败Console.WriteLine("CosServerException: " + serverEx.GetInfo());}
说明
查询静态网站配置
功能说明
GET Bucket website 用于查询与存储桶关联的静态网站配置信息。
示例代码
try{// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.cloud.tencent.com/developerstring bucket = "examplebucket-1250000000";GetBucketWebsiteRequest request = new GetBucketWebsiteRequest(bucket);//执行请求GetBucketWebsiteResult result = cosXml.GetBucketWebsite(request);//请求成功Console.WriteLine(result.GetResultInfo());}catch (COSXML.CosException.CosClientException clientEx){//请求失败Console.WriteLine("CosClientException: " + clientEx);}catch (COSXML.CosException.CosServerException serverEx){//请求失败Console.WriteLine("CosServerException: " + serverEx.GetInfo());}
说明
删除静态网站配置
功能说明
DELETE Bucket website 用于删除存储桶中的静态网站配置。
示例代码
try{// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.cloud.tencent.com/developerstring bucket = "examplebucket-1250000000";DeleteBucketWebsiteRequest request = new DeleteBucketWebsiteRequest(bucket);//执行请求DeleteBucketWebsiteResult result = cosXml.DeleteBucketWebsite(request);//请求成功Console.WriteLine(result.GetResultInfo());}catch (COSXML.CosException.CosClientException clientEx){//请求失败Console.WriteLine("CosClientException: " + clientEx);}catch (COSXML.CosException.CosServerException serverEx){//请求失败Console.WriteLine("CosServerException: " + serverEx.GetInfo());}
说明