Website configuration using the Amazon S3 Java SDK
In previous chapters, we saw how to create a bucket and upload objects (files) to the bucket. Here, we will take a look at how we can create a new bucket, upload index.html
and error.html
files, and configure the website for the bucket.
To set the bucket website configuration, we have a method in Amazon S3, as follows:
s3.setBucketWebsiteConfiguration(bucketName,new BucketWebsiteConfiguration(indexHTML, errorHTML));
Here, bucketName
the name of our bucket, in which the website source code will be added. The indexHTML
and errorHTML
parameters are the landing and error pages, respectively, which are specified to the bucket website configuration. In case an error occurs, the errorHTML
page will be displayed.
To get the bucket website configuration, we have a method in AmazonS3, which is as follows:
BucketWebsiteConfiguration configuration = s3.getBucketWebsiteConfiguration(bucketName);
Here, bucketName
will be passed, and we need to fetch its bucket...