How To Set Up and Host A Publicly-Accessible File on Amazon S3 (Simple Storage Service)

Avatar of Chris Coyier
Chris Coyier on

usings3.png

One of the many good suggestions I got for hosting these video files was to use the Amazon S3 (Simple Storage Service). I had heard about this before, but didn’t know much about it. Nothing like trial by fire to figure something out quickly…

 

Step 1: Sign up for Amazon Web Services

Simple enough. Go here to do this. There are other different web services Amazon offers. The one we are using here is the Simple Storage Service). You will get a chance to see the rates on this page, but just for kicks, here they are:

Storage
$0.15 per GB-Month of storage used

Data Transfer
$0.10 per GB – all data transfer in
$0.18 per GB – first 10 TB / month data transfer out
$0.16 per GB – next 40 TB / month data transfer out
$0.13 per GB – data transfer out / month over 50 TB

Requests
$0.01 per 1,000 PUT or LIST requests
$0.01 per 10,000 GET and all other requests*

That basically reads: “Super cheap bandwidth for sale!”

 

Get your Access Key ID and Secret Access Key

Click the little yellow dropdown graphic and select AWS Access Identifiers. You will see a graphic like this. Click the show button to show your secret access key.

accessstuff.png

This is basically your “User Name” and “Password” for logging into this service. One of the weird things about this is that Amazon provides no way to access this service themselves. Nor do they provide any information on third party tools in which to use, at least that I could find.

 

Download a Third Party Tool

The best way I’ve found is to use Transmit from Panic. It is their flagship FTP tool, which it’s great for, and it offers Amazon S3 as one of the regular server types so it’s super easy to use for this.

usingtransmit.jpg

If you aren’t on a mac, there are other tools to connect to Amazon S3. The first tool I tried was actually Bucket Explorer and also did a fine job, just wasn’t quite as nice as using my already loved Transmit.

Connect, and Create a Bucket

Once you get connected, you’ll need to create a bucket (basically just a directory, to keep you organized) in which to upload your file. Buckets are “globally unique” meaning that the name of your bucket cannot be the same as anyone elses in the world. So if you want your bucket to be called “images”, too bad =) — try something like the name of your website or your last name.

newbucket1.jpg

 

Upload your file(s)

This should be a pretty easy thing to do no matter what tool you are using. In the case of transmit, just double click your new bucket open and then drag files either directly from the finder or from the left-hand navigational pane into the right area.

 

Making the files public

Now that your file is uploaded, you need to do this step to make it actually publicly accessible. Since I was using this to embed video on a web page, this was a must. I forgot to do this once, and the video just didn’t work. Took me a few minutes of head scratching to realize I forgot to make it publicly accessible.

In the case of Transmit, right click on the file and go to “Get Info”.

getinfotransmit.png

This is where you need to change the Permissions for the Read setting to World. Now your file should be link-able. But what is the URL for that file?

 

Getting the URL for your hosted file

Again, in the case of Transmit, this is really easy. Just right click the file and go to “Copy Path”.

copypath.png

Or, you can just create the URL yourself. It’s very easy to figure out:

http://s3.amazonaws.com/YOUR-BUCKET-NAME/YOUR-FILE-NAME

Embed your video

If you are using this to host video like I am, now you can link directly to this file from your embed code.

<EMBED src="//s3.amazonaws.com/YOUR-BUCKET-NAME/YOUR-FILE-NAME" width="800" height="461" autoplay="false" controller="true" cache="true" loop="false" bgcolor="#000000" pluginspage='http://www.apple.com/quicktime/download/'></EMBED>

One of the little scary things about doing it this way is you are exposing that link for all to see. In case someone was out there trying to poach your content, they could link directly to this and use your bandwidth. I guess you’ll have to monitor your Amazon S3 statistics to see that. Hopefully they can show you that kind of information, I haven’t dug into this that far yet.

Good luck!