Unzipping to Amazon S3 with CF

I was working on a project today and one of the requirements was a zip file with many nested folders needed to be uploaded and extracted to an Amazon S3 bucket. I originally expected this to be trivial, just use cfzip's script implementation and point it at the S3 destination. Simple right?

It would have been, except CF has no cfscript implementation of cfzip, oh and by the way, even if it did, you can't point cfzip to an AmazonS3 bucket...woops! Well THAT was embarrassing.

So I was forced to come up with it on my own. I'm sure people can come up with much smarter ways to do this than what I did, but, I needed it quick and here is what I came up with.


This is a really simple implementation of cfzip to be used in cfscript, used Todd Sharp's suggestion on a comment from Ray Camden's blog. The only difference is I drop all my script implementations of CF tags in a utility cfc.

myController.cfc (only showing the relevant code)

I had to modify a bit of the code for the blog entry so there might be a bug or two in the rewrite. It's late so I'm not going to test it tonight but I'll correct any errors tomorrow morning.