Seven steps to use S3 as a media server.

16Oct06

So I’ve just started experimenting with Amazon’s S3 service and boy is it easy. My plan was to use S3 as a media server to serve up my flash widgets and javascripts for my upcoming Quizical.net project. So to do that, I ….

  • created an S3 account.
  • Dowloaded the S3 Organizer plugin for Firefox.
  • Restarted firefox and opened up S3 Organizer.
  • Created a “bucket” (basically a new folder). To do this, it is just like creating a folder with an FTP client.
  • After my bucket was created (I called it “quizical”), I uploaded the image, javascript, and stylesheet directories of my rails app.
  • Using S3 Organizer, I set my permissions to public for these directories, by right-clicking on the file name and setting public in the dialog box and checking the “Apply to sub-folders” box.
  • In production.rb in config/environments, I revised this line to point to my asset server:
    config.action_controller.asset_host = “http://quizical.s3.amazonaws.com”

Now all of my public files are being served from S3, a true asset server. So simple.

The only thing that threw me off for a second was the terminology used. The bucket reference I got. But the URL structure is listed as http://s3.amazonaws.com/bucket/key. I kept putting in my access key for the /key. Turns out, key is what Amazon calls the filename.



3 Responses to “Seven steps to use S3 as a media server.”

  1. Hello,

    nice little guide. i’ve been thinking about using s3 for a while, i’d be grateful if you could confirm something. so in the html on your website in order to reference say, “test.js” from your s3 account, you simply add a url like so?

    http://quizical.s3.amazonaws.com/test.js

  2. Sagey, yes that’s right. You do have to make sure you’ve set the ACL (access control list) to allow public access to that file. You can also have subdirectories.

  3. 3 Hector

    If you rename the bucket to something like “static.quizical.net”, you can setup a CNAME record pointing to static.quizical.net.s3.amazonaws.com. This will allow you to reference files via http://static.quizcal.net/test.js


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: