Using S3 to Store Media Files
Adrian Holovaty is now using Amazon’s S3 to store files for his Chicago Crime site. In his recent blog post, “How I’m using Amazon’s S3 to store media files“, he describes the entire process of moving his files over. Adrian notes that it took him less than one hour to move his files over and to modify his code.
One of the commenters to the blog was surprised to find out that the objects in S3 are URL-addressible. This is absolutely the case, and is one of the very cool aspects of S3.
In fact, the image at right is stored within S3; I put it there using the S3 Perl / Curl sample.
You can verify this by right-clicking on the image and inspecting its properties. The image’s URL is http://s3.amazonaws.com/aws_blog/images/chicago_crime.png . In this case, aws_blog identifies the S3 bucket, and images/chicago_crime.png identifies the object (the image) within the bucket.
When I stored the image into S3 I set the content-type to “image/png” so that the browser would know that it was in fact an image. When S3 processes the HTTP GET from the browser, it returns the content type (along with any other S3 metadata attached to the object) using HTTP headers. Here’s what it returned for the image:
As you can see, it would be easy to use S3’s metadata facility to store exta information about each object. Once information is stored in S3, you can get it back without retrieving the entire object using a simple and efficient HTTP HEAD request.