Serving Files from Amazon's Simple Storage Service (S3)

Media files such as images, music or video can place a huge load on your server. The following image is actually being served from Amazon's S3 service - the file has been tagged as having public read-only access. Amazon charges me $0.18 per Gigabyte for files served like this. The URL incorporates the name of my S3 bucket, "" and the name the file is stored under "Jan17IceStorm.jpg".

Controlled Access for Customers

Another simple use for S3 is to serve bulky files to customers without using your own server's bandwidth. You can control who has access to the files by tagging them in S3 as private and providing your customer a signed URL valid for a limited time. I simplified examples from Amazon's S3 Java library to create a servlet that generates a redirect URL using my private key. The steps involved can be summarized as:

The final URL includes the S3 host, bucket name, file name, public key ID, expiration date and signature. This URL is used in a typical servlet response sendRedirect( url ) method.

Here is an example with PDF files. The form submits data to my redirecting servlet which generates a signed limited time URL. Note that Amazon S3 recognizes the file type and assigns a request header Content-Type of application/pdf so your browser should show these in an Acrobat plugin reader.

Amazon S3 References

Amazon Web Services starting page.

Introduction to Amazon Web Services for Java developers.

Using Amazon S3 for backup.

A Wikipedia article on the "Slashdot Effect".

Amazon Web Services article on configuring S3 to let a small company handle a huge server request load.

My article on using S3 for backup with Java.