Streaming MP3s from Amazon S3

netflux picture netflux · Mar 27, 2009 · Viewed 31.6k times · Source

Is there a way to stream MP3s stored on Amazon S3 via a Flash widget embedded in a website, or some other method?

Answer

Konstantin Tarkus picture Konstantin Tarkus · Mar 27, 2009

Yes it is. Firstly, you need to create a bucket in your S3 account which is all in lower case, is globally unique and is DNS-compatible; so for example I created a bucket called ‘media.torusknot.com’.

Then to make it all look nice you need to create a DNS CNAME entry to map a sub-domain of your site to that S3 bucket. That will allow you to access your files you upload to that S3 bucket via ‘http://media.example.com/somefile.mp3’. You do just need to set the ACLs on the files & the bucket to make sure public access is allowed.

Finally, if you want to stream video files via a Flash player from S3 to another domain, you also have to tell Flash that it’s ok for the content to be pulled in from a different domain. Create a file called ‘crossdomain.xml’ in the bucket, with these contents:

<cross-domain-policy>
<site-control permitted-cross-domain-policies="all"/>
</cross>

That allows the media to be accessed from anywhere - you can be more specific if you want but this is the simplest approach.

Related resources: