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:
%form{:action=>"/Upload",:method=>"post",:enctype=>"multipart/form-data"}
- @theModelHash.each do |key,value|
%br
%input{:type=>"checkbox", :name=>"#{key}", :value=>1, :checked=>value}
=key
%br
%input{:type=>"file",:name=>"file"}
%input{:type=>"submit",:value=>"Upload"}
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.
Best Answer
The process is usually the following: (from four.livejournal.com/730831.html)
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).
HTH!
links