Bucket静态网站托管
更新时间:2022-09-14
将网站托管在Bucket上,实现轻量化运维,如下代码可以做到:
参数 | 说明 |
---|---|
index | Index文件名称 |
notFound | 404文件名称 |
public void PutBucketStaticWebsite(BosClient client, String bucketName, String index, String notFound) {
SetBucketStaticWebsiteRequest setBucketStaticWebsiteRequest = new SetBucketStaticWebsiteRequest();
setBucketStaticWebsiteRequest.setBucketName(bucketName);
setBucketStaticWebsiteRequest.setIndex(index);
setBucketStaticWebsiteRequest.setNotFound(notFound);
client.setBucketStaticWebSite(setBucketStaticWebsiteRequest);
}
若用户想查看静态网站托管信息,则如下代码可以做到:
public GetBucketStaticWebsiteResponse GetBucketStaticWebsite(BosClient client, String bucketName) {
GetBucketStaticWebsiteRequest getBucketStaticWebsiteRequest = new GetBucketStaticWebsiteRequest();
getBucketStaticWebsiteRequest.withBucketName(bucketName);
GetBucketStaticWebsiteResponse resp = new GetBucketStaticWebsiteResponse();
resp = client.getBucketStaticWebsite(getBucketStaticWebsiteRequest);
return resp;
}
若用户想关闭静态网站托管功能,则如下代码可以做到:
public void DeleteBucketStaticWebsite(BosClient client, String bucketName) {
DeleteBucketStaticWebsiteRequest deleteBucketStaticWebsiteRequest = new DeleteBucketStaticWebsiteRequest();
deleteBucketStaticWebsiteRequest.withBucketName(bucketName);
client.deleteBucketStaticWebSite(deleteBucketStaticWebsiteRequest);
}