Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Paperclip to direct upload files to S3

so I've got paperclip set up with uploadify to upload things to S3. I have made my setup so that stuff gets loaded directly to S3 and then when it's done I post to my webserver the results...

All I get back is the file name and size. am I supposed to build my own processor or before_post_process method to "download" the file from S3 in order to process it? or am I missing something and uploadify should have provided me a stream with the file inside it after it was done posting to S3?

How do you guys go about direct uploads to S3 and then notifying your paperclip backed model? Do you have to pull files from the server and do post-processing on them or will paperclip handle all of that?

like image 693
schone Avatar asked Feb 18 '11 03:02

schone


People also ask

How do I upload files to AWS S3?

In the Amazon S3 console, choose the bucket where you want to upload an object, choose Upload, and then choose Add Files. In the file selection dialog box, find the file that you want to upload, choose it, choose Open, and then choose Start Upload. You can watch the progress of the upload in the Transfer pane.

How many ways you can upload data to S3?

You have two options for uploading files: AWS Management Console: Use drag-and-drop to upload files and folders to a bucket. AWS CLI: With the version of the tool installed on your local machine, use the command line to upload files and folders to the bucket.


1 Answers

Here are a couple blog posts describing how to do it...

http://www.railstoolkit.com/posts/uploading-files-directly-to-amazon-s3-using-fancyupload

http://www.railstoolkit.com/posts/fancyupload-amazon-s3-uploader-with-paperclip

They use FancyUploader (which uses MooTools/Flash) to upload directly to S3, bypassing Heroku and their dreaded 30 second request timeout all together, and then use DelayedJob to queue up post-processing tasks like thumbnailing and PaperClip to do the actual processing of the files.

If I can get this working with CarrierWave, I will post up a project on GitHub to share (in a week or so once I get time)

Update:

Sample project using Rails 3, Flash and MooTools-based FancyUploader to upload directly to S3: https://github.com/iwasrobbed/Rails3-S3-Uploader-FancyUploader

Sample project using Rails 3, Flash/Silverlight/GoogleGears/BrowserPlus and jQuery-based Plupload to upload directly to S3: https://github.com/iwasrobbed/Rails3-S3-Uploader-Plupload

I will add the post-processing example once I have time.

like image 110
iwasrobbed Avatar answered Oct 24 '22 15:10

iwasrobbed