Adventures with Amazon S3 and Flash

 

Amazon S3 is a cost effective online storage solution. But more than just being a place for you to store or back up files, it can also be used to serve files out to the web. So having recently launched 100 Feelings Felt which stores images on a server, I didn’t want those images taking up valuable space on my web server. I thought to myself S3 could come in handy here.

So it was then I started doing some digging around. There’s some great technical documents on the Amazon S3 site which helped me on my way to finding a solution. There was this great article on scalable media hosting which got me thinking about all this in the first place. But this didn’t talk about dynamic uploading of images it was more about serving out media.

Next though I found this article about browser based uploads. This was more like it. So I set to putting this on my server and getting this working as a test.

The first stumbling block I came across was the fact that any upload request needs a signed policy file and a signed signature. A what? The above link has some code in various languages to show you how to create such a thing (basically a base64 encoded piece of text) but that all looked like to much work for me. As luck would have it I found this wonderful page that creates everything you need via php, and without the need for any of that PEAR stuff or PHP 5!

Armed with my policy file and signed signature I then plugged it into the browser based upload example and it worked a treat. Great. All I now need to do is find some Flash Amazon S3 class library or code and we should be good to go?

Almost. I found this message on the Amazon S3 forums which had handy links to all the code I needed to send an image created in Flash to S3. Except for almost a day I was puling my hair out. I just kept getting back errors that the policy file didn’t match the POST data. Yet it worked fine in the HTML version. And then I found this message that talked about 403 errors in Flash uploads. So I read it carefully again, after taking a break to watch a film.

And I then I saw the bit I was missing. I’d left out the “filename” condition from my policy file. So I amended the file and ta da! It worked.

Now I have images for 100 Feelings being saved on Amazon S3 and no longer do I need to worry about running out of disk space on my server. Now I have a scalable, cost effective pay-as-you-go solution in place thanks to Amazon. I hope this little piece helps other Flash people out when looking to use the wonderful S3 for storing and serving media.

Thank you for this information…
When I’ll have some time I will so some experiments with Amazon S3 :)

vamapaull /

[…] Adventures with Amazon S3 and FlashBren talks about his experiences with Amazon S3 and Flash. […]

Why I’m not working for 2008-11-11 / 2008-11-17 | CISNKY /
Leave a comment: