Appcelerator Titanium - Connecting and uploading to CloudFiles Rackspace Storage

Appcelerator Titanium - Connecting and uploading to CloudFiles Rackspace Storage

July 15, 2012

I wrote this about 8 months ago in order to connect to Rackspace's "CloudFiles" platform, which is basically a CDN like Amazons S3 or a stack of others out there.

I use Rackspace for pretty much all my hosting and recommend them to all my clients, so CloudFiles made more sense for my purposes than S3 did. Here's a link to the CloudFiles page and there's a PDF there with the API specifications: http://www.rackspace.com/cloud/cloud_hosting_products/files/api/.

Anyway, here's the CommonJS module free for you to use. I've not implemented all the CloudFiles features, so feel free to extend this and share it again. One thing to note - at the time I wrote this there was a bug in the Appcelerator SDK whereby you couldn't set the Content-Length parameter under Android when using the PUT command - Rackspace requires this to be set. I'm not 100% sure if this bug has since been fixed in 2.0+ releases of the Titanium SDK.

The CommonJS module (copy, paste and save as "CloudFiles.js")

Here's a sample of using it to authenticate and push an image file (Snippt not fully tested!). The module does work, I have it in a few production apps, but I don't have time to write a full sample... I'm sure you can all work it out anyway!