Book Image

Amazon S3 Essentials

By : Sunil Gulabani
Book Image

Amazon S3 Essentials

By: Sunil Gulabani

Overview of this book

Amazon Simple Storage Service (Amazon S3), provides developers and IT teams with secure, durable, and highly-scalable object storage. Amazon S3 is easy to use, with a simple web services interface to store and retrieve any amount of data from anywhere on the web. S3 is automatically web scalable and responds to the requirements of your application and traffic, and therefore offers a key element to help companies deal dynamically with any spike in traffic for their application (such as a free e-book offer). This book starts with the basics of the Amazon S3 and its features, and you will quickly get an understanding how to use the Amazon Management Console for Amazon S3 which is the simplest way to manage Amazon S3. Next, we will cover basic operations on bucket, folder, objects. Once the basic operations are understood, you will know how to use Amazon S3 using Java SDK. Following that, you will learn about Copy Objects and Multipart copy objects for large objects size. You will also learn to manage the life cycle of bucket and how to share resources to the different domain by configuring CORS. The book will then guide you through the development and deployment of a static website on Amazon S3 using different services of Amazon. By the end of the book, you will be able to create a scalable application using Amazon S3.
Table of Contents (12 chapters)

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...