<img src=“http://travis-ci.org/dombesz/thin_upload.png” />
gem install thin_upload --pre
In your Gemfile
gem "thin" gem "thin_upload", "~> 0.0.1.pre"
Note: Works only with thin server!
Upload progress is available for any file upload request.
Example:
<iframe id="upload_frame" name="upload_frame" style="width: 0px; height: 0px;"></iframe> <%= form_tag(photos_path, {:multipart => true ,:target=>"upload_frame"}) do %> <%= text_field_tag :uuid, UUID.new.generate %> <%= file_field_tag :file %> <p><%= submit_tag "Continue →".html_safe, :id=>'submit_form' %></p> <% end %>
To have progress tracking, we need to send a +uuid param in the submited form, and the +uuid param MUST be before the file field.
If you want to ask for progress use get request.
$.getJSON('/progress?uuid='+$("#uuid").attr('value'),function(response){ //process response });
While your upload is processing you can request the progress from rack.
@progress = request.env['rack.progress'][params[:uuid]] @progress is an integer in range 0..100 or nil if doesn't exists
Note: This is just an experiment, it’s not production ready. Any suggestions are welcome.