Sticky Posts
Nov 22, 2009
Create Temporary (Expiring) Links With Amazon S3 & PHP
Building Amazon S3 temporary URLs is quite a cool thing especially if you plan to sell digital downloads you will not feel comfortable sharing from your own server. These links will have an expiry time and won't be usable after that period. It's the perfect way to make a link expire in 5 mintes. Enough time to start the download and stay safe on your side.
I will not explain the process of creation as it's pointless. It's one of those little things you just need to work. It can also be used as a signature building example for those who want to dig deeper in the S3 programmable core.
Have fun:
Registration is FREE, quick, painless and worth its weight in gold.
Use like this:
$url = el_s3_getTemporaryLink(S3AccessKey, S3SecretKey, 'bucket', 'folder/file.ext', 5);
... builds a 5 minutes URL to http://bucket.s3.amazonaws.com/folder/file.ext


Good stuff. I created my own class to do this and have used it to distribute application updates. Works like a charm and the logging options S3 provides are great. Another cool trick that a lot of people aren’t aware of is that you can create torrent links through S3 very easily. Great feature for community sites.