Static website hosting

Last Updated: Jun 01, 2017

We mentioned in Binding Custom Domain Names 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 need to 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, refer to OSS 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.