mongreleers,

This is a hack for adding basic upload progress support to Mongrel. Currently, you can monitor the upload of any POST. I'm sure some work needs to be done to get it functioning with Rails.

Save as lib/mongrel/progress.

Anyway, here's how to start Mongrel with it:

 require 'mongrel'
 require 'mongrel/camping'
 require 'mongrel/progress'
config = Mongrel::Configurator.new :host => host do
   listener :port => port do
     uri "/", :handler => Mongrel::Camping::CampingHandler.new(ParkPlace)
     uri "/progress", :handler => Mongrel::ProgressHandler.new
     uri "/favicon", :handler => Mongrel::Error404Handler.new("")
     trap("INT") { stop }
     run
   end
 end
 config.join

Yeah, so, notice the ProgressHandler class and the require.  In your forms:

 <form action="?upload_id=XXX" enctype="multipart/form-data">...</form>

Since the handler is mounted at '/progress', you can hit '/progress?upload_id=XXX' to read the stats:

 size: 55575
 received: 11131

Left to do:
 * XML/YAML/JSON output. (based on the Accept header.)
 * Support for X-Upload-ID, X-Progress-ID, progress_id. (?)

_why

Attachment: progress.rb
Description: application/ruby

_______________________________________________
Mongrel-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/mongrel-users

Reply via email to