NYCPHP Meetup

NYPHP.org

[nycphp-talk] 3rd Part or Cloud Hosting for SWF Files

Rob Marscher rmarscher at beaffinitive.com
Wed Sep 22 14:51:51 EDT 2010


On Sep 22, 2010, at 2:36 PM, Chris Snyder wrote:
> I'm not sure if you could still use CloudFront without translating the
> file names in the SWF or XML, but you should be able to use plain old
> S3 transparently.

If you have control over your dns, I'd recommend creating CNAME dns records for your S3 and CloudFront hostnames.  Makes it transparent that the images are hosted by Amazon.  Might help with the file names issue.  If you're xml/swf file can use relative filenames, then you should be able to use CloudFront or S3.  http://docs.amazonwebservices.com/AmazonS3/latest/index.html?VirtualHosting.html

Some notes for working with S3: you need to pass an acl for the files that allows public access.  By default, files are private.  For images that are never going to change, you can set a far future "Expires" header for the file that will let browsers cache them.

Also, you'll probably need to upload a crossdomain.xml file to s3 too for your swf to work.

Since you're using Zend Framework, I assume you would use their classes for managing it: 
http://framework.zend.com/manual/en/zend.service.amazon.s3.html

So when you call $s3->putObject, you want to pass an array to the third $meta argument like this:

array(
	Zend_Service_Amazon_S3::S3_ACL_HEADER => Zend_Service_Amazon_S3::S3_ACL_PUBLIC_READ,
	'Expires' => strtotime('now +10 years')
));

If you know the mime type already, you can also pass that to the self::S3_CONTENT_TYPE_HEADER key of the $meta array, otherwise the Zend_Service_Amazon_S3 class guesses it based on the extension.

-Rob




More information about the talk mailing list