Skip to content

dombesz/thin_upload

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

<img src=“http://travis-ci.org/dombesz/thin_upload.png” />

Install

gem install thin_upload --pre

Usage

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 &rarr;".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.

About

A gem for tracking file upload progress for thin server

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published