Static website hosting

Last Updated: Oct 23, 2017

In Bind custom domain names, it is mentioned that the OSS allows you to direct your domain name to the OSS service address. In this way, the OSS bucket is accessed when you access your website. You must specify the names of the objects in the bucket corresponding to the homepage (index) and error page (error) of the website respectively.

For more information about static website hosting, see Static website hosting.

Set website hosting

You can use OSSClient.setBucketWebsite to set website hosting:

  1. SetBucketWebsiteRequest request = new SetBucketWebsiteRequest("bucketName");
  2. request.setIndexDocument("index.html");
  3. request.setErrorDocument("error.html");
  4. ossClient.setBucketWebsite(request);

View website hosting

You can use OSSClient.getBucketWebsite to view website hosting:

  1. BucketWebsiteResult result = ossClient.getBucketWebsite("bucketName");
  2. System.out.println(result.getIndexDocument());
  3. System.out.println(result.getErrorDocument());

Clear website hosting

You can use OSSClient.deleteBucketWebsite to clear website hosting:

  1. ossClient.deleteBucketWebsite("bucketName");
Thank you! We've received your feedback.