Image Uploads to AWS S3 using Rails 3, Paperclip and PLUpload

For the Invest Your Heart project, I’ve been working on getting image uploads perfected. That’s easy enough with the Paperclip gem. But storing uploads on your Heroku dyno isn’t a good idea, so I wanted to use S3. Oh and throw in upload previews, resizing and a progress bar.

I managed to get it all working, though it took a lot because there are so many moving parts. I’m using the PLUpload code to provide uploads and progress var interface and Paperclip for resizing. And I’m uploading directly to S3, to avoid timeouts on Heroku when large files are uploaded. After the initial upload, Paperclip actually downloads the image, processes it, and uploads the different resized versions back to S3.

I couldn’t have done it without these two incredibly helpful sites: The Rails-S3-Plupload demo project, and Swarut’s post. Thanks guys! I would never have gotten it working without you.

Swarut also turned me on to the Gon gem which provides a simple way to send data from your controllers and JS variables. Very handy for when your app doesn’t need something like Backbone.js