poseid
poseid

Reputation: 7156

Rails: how does background file upload work?

Uploading a file in a REQUEST/RESPONSE cycle for large files is not a nice experiences for the user, because the application seems to hang during the file upload. Even more critical is that the user can abort the upload, and need to re-start the upload process later.

How can I do the upload process in the background?

There are some examples of running background tasks in rails on railscasts.com but it's not clear to me how to integrate a background job with a file upload.

On other places, I see that I need some webserver tuning for this, but then I need to ask the folks from my shared host for technical support on this?

Upvotes: 4

Views: 1856

Answers (1)

iwasrobbed
iwasrobbed

Reputation: 46703

If you are using Rails 3, please check out my sample projects which allow you to upload directly to S3 and offload the work from the app. Then you can just use delayed job to do secondary operations:

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

By the way, you can do post-processing with Paperclip & delayed_job using something like this blog post describes:

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

Upvotes: 4

Related Questions