开发者

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?


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.


You can either create a processor or use the callback methods but the file will definitively be on your server before going to S3.

If you are in the callback method for example you can access it using something like:

self.file.to_file

Once that is done processing and uploading the file will be deleted from your server. You don't need to do anything to notify or post process. Paperclip will handle it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜