My Photo

« The Lego Era | Main | Saturday Morning S3 Roundup »

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:

HTTP/1.1 200 OK
x-amz-id-2: 0K7SmOorLULRBZUjPRDyQruOsnGkOYwcwIMz5nezKFjMVWsDgi099lZvY4qUCOsG
x-amz-request-id: 52F4A02FC0C51299
Date: Fri, 07 Apr 2006 18:12:23 GMT
Last-Modified: Fri, 07 Apr 2006 18:05:29 GMT
ETag: "4f81c616c6e0e65dc6c957681941a3f4"
Content-Type: image/png
Content-Length: 75860
Connection: keep-alive
Server: AmazonS3

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.

-- Jeff;

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d8341c534853ef00d834b77ebc69e2

Listed below are links to weblogs that reference Using S3 to Store Media Files:

Comments

Jeff

Any plans to add support for DNS also? (i.e. instead of http://s3.amazonaws.com, I want http://images.mycorp.com)

Dave, it seems that although technically breaking strict HTTP spec, you can set up a CNAME to point to the regular S3 domain.
This is an "unsupported feature" which, it seems, may not always work in the future.

You can read more about it in the S3 forum.
http://developer.amazonwebservices.com/connect/thread.jspa?threadID=10246&tstart=15

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been saved. Comments are moderated and will not appear until approved by the author. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Comments are moderated, and will not appear until the author has approved them.

Email Subscription

Enter your email address:

Delivered by FeedBurner

July 2009

Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31