Using Paperclip to direct upload files to S3

痴心易碎 提交于 2019-11-30 04:14:12

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!