25. 08. 2009

FancyUpload Amazon S3 Uploader with Paperclip

In the previous (and first) post on this Blog I wrote about how to to upload files directly to Amazon S3 using FancyUpload. This post describes how to extend the uploader so that for each file successfully uploaded to S3 a rails model with a paperclip attachment (the uploaded file) is generated. This is useful for keeping track of the uploaded files from within a rails application and for applying post processes like thumbnail generation. I chose the paperclip plugin because I find it provides the easiest way for adding attachments to a rails model.



Conveniently, paperclip already has a S3 storage module built in. However it assumes that files are first uploaded to the webserver and then to S3. So to make paperclip work with files that are already uploaded to S3 I needed to slightly modify the S3 module in paperclip.

Comments: 6
Read all...


12. 08. 2009

Uploading files directly to Amazon S3 using FancyUpload

I'm happy to share some pieces of code I created to upload files directly to Amazon's S3 data storage, using the great flash based uploader FancyUpload.



Commonly, when using S3 as a data storage with rails, e.g. with paperclip, files are first uploaded to the webserver, potentially a post process follows and finally the files are uploaded to S3. The obvious advantage of directly uploading to S3 is that each file is only uploaded once (for files that don't require post processing). Another advantage is that the webserver is not touched at all saving its resources for serving pages.

Comments: 23
Read all...