I need to be able to allow a user to upload 30-60 mb files at a time. Right now, I'm solving the problem with a simple form post:

 - @theModelHash.each do |key,value|
   %input{:type=>"checkbox", :name=>"#{key}", :value=>1, :checked=>value}

This form allows the user to select processing options contained in theModelHash and upload a file for processing. Problem is, this method both freezes the user's UI and also requires that the entire form be reposted when the user presses the 'back' button.

I've looked at SWFUpload, but have no idea how to integrate that into my relatively simple app. There's a page here about integrating it with Rails, but I'm using Sinatra, and am new enough to this whole web programming thing that I don't know how to modify those files to work with what I need to do.

Is there a how-to to add large file uploads to my form there? Something relatively simple that just adds in a progress bar and doesn't repost? I feel like I'm having to triple the size of my application just to make this feature play nice, and that's bothering me a bit.


The process is usually the following: (from four.livejournal.com/730831.html)

HTTP upload progress bars are rather obfuscated- they typically involve a process running on the server keeping track of the size of the tempfile that the HTTP server is writing to, then on the client side an AJAX call is made every couple seconds to the server during the upload to ask for the progress of the upload.

In order to do that, you need to install a module on your web server (be it apache(1), nginx(2) or lighttpd(3)). Which means that you can't run your Sinatra app as a standalone (ruby sinatraapp.rb), but that you have to run it through(4) one of the aforementioned webservers. The easiest way is to use Passenger(5).

For the client-side AJAX polling, try Ajax Upload(6).



  • (1): piotrsarnacki.com/2008/06/18/upload-progress-bar-with-mod_passenger-and-apache/
  • (2): wiki.nginx.org/NginxHttpUploadProgressModule
  • (3): redmine.lighttpd.net/wiki/1/Docs:ModUploadProgress
  • (4): blog.zerosum.org/2008/7/4/passenger-3-sinatra
  • (5): modrails.com/
  • (6): valums.com/ajax-upload/
  • Thanks! I'll check it out, using this and the solution on the StackOverflow question. – mmr Aug 9 '10 at 15:03

you can get upload progress with: http://github.com/drogus/apache-upload-progress-module

i have not used any self-contained module as such for file upload.

  • That's for apache. I thought that the two were very different... – mmr Jun 5 '10 at 0:29
  • The question is asking how to do this using nginx not apache. – slm Dec 22 '12 at 3:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.