Setting up Amazon S3 to host my blog was easy. Following the steps of the walkthrough, it took about an hour to have the site up and running.

One thing I wanted to make sure is that the urls of my website would not contain the .html extension. For example, compare the URL of the page you're viewing now with the alternative http://markteisman/s3cmd.html.

It turns out that arranging this is easier said than done. The thing is that Amazon tries to infer the MIME type of the content based on the file extension. This means that a file called s3cmd.html would be served with the HTTP header Content-Type: text/html. When the file extension is lacking, the S3 static server sets the Content-Type header to the default application/octet-stream.

True, the MIME type can easily be overridden on a file-by-file basis by manually setting it via the Amazon Console. However, this can be a laborous task if you serve many files, and it is something I definitely do not want to worry about every time I upload files to my bucket.

Luckily, there are tools available that allow you to upload files to your bucket from your command line, and that allow you to set the MIME type while you're at it. I decided to install a tool called s3cmd. First, install s3cmd.

git clone https://github.com/s3tools/s3cmd.git
cd s3cmd/
python setup.py install

Now, to check whether the program was installed successfully, run s3cmd --version. After s3cdm is installed correctly, it is time to configure it with your Amazon S3 keys. First, run s3cmd --configure. Supply it the keys that can be found on Amazon's security credentials page. Then walk through the configuration wizard - you will be asked to enter an enctryption key, specify the path to the GPG program, and whether you want to use to transfer your data over the TLS protocol. Finally you will be asked whether you want to save your settings. Your settings will be saved in $HOME/.s3cfg.

It is easy to do some basic nagivation through your buckets. You'll see I have two buckets, and that the first one contains a file called index.html.

$ s3cmd ls

$ s3cmd ls s3://markteisman.com
2013-08-15 20:22      8713   s3://markteisman.com/index.html

Now, to upload a file at $HOME/articles/s3cmd (i.e. this article) while setting the MIME type to text/html, enter the following command:

s3cmd put --acl-public --mime-type=text/html \
$HOME/articles/s3cmd \ 

That was it. This should be enough to get you started.

Goodbye folks!

Copyright 2013 by Mark Teisman.
Content licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.