7 July 2009
Amazon S3 Tricks
We use Amazon S3 as an easy and cheap CDN on many projects. Here’s some interesting things I learned recently while researching how to stop direct downloading or linking to media files:
- Any file on S3 can be turned into a torrent by adding ?torrent to the filename. As in http://bucket.s3.amazonaws.com/myfile.zip?torrent. I read about this over here.
- S3Stat looks like a useful tool for viewing your S3 logs. In particularly, checking for direct linking from other sites.
- You can make auto expiring links using S3 (documentation here). This is the meat of what I wanted to find out. Using the Query String Request Authentication (page 24 of the PDF) you can specify an expire time for a link. As I take it (and we haven’t implemented this yet, so I’m not positive), you would set the read access of the file to “Authenticated Users.” Then you would construct the URL to the file using your public AWS access key, the expire time, and then a signature that includes a hash of your request with the expire time and your private key. So if you set the expire time to something only a few seconds after the current timestamp, that link should not be useable again.