Zed Shaw
2006-Sep-04 23:37 UTC
[Mongrel] [ANN] Mongrel Upload Progress 0.2 -- With Instructions and Examples
Hi Folks, I''m sure tons of people are gonna ruin a whole drawer of their best panties over this one. Rick Olson worked on the mongrel_upload_progress gem, documentation and examples and has almost everything you need to do progress tracked file uploads using just Mongrel to handle the upload. This means that Rails (or any other framework) isn''t blocked while the upload happens, and that the user gets nice status. Here''s Rick''s blog post: http://weblog.techno-weenie.net/2006/9/4/mongrel-upload-progress-documentation You can watch a snazzy video of Rick playing with it at: http://s3.amazonaws.com/techno-weenie-screencasts/mongrel_drb.mov Then you can read the instructions and get sample code from: http://mongrel.rubyforge.org/docs/upload_progress.html Which includes installation instructions, sample rhtml forms, javascript, and Rails actions to get you started. It''s not limited to Rails though, that''s just the example Rick did, since, well, Rick does Rails. This is still early, so patches and suggestions are welcome. And everyone should thank Rick and _why_t_l_s for working on this with me at RailsConf, and especially Rick for doing the heavy lifting of integrating it with Rails and documenting it. WRITING PLUGINS The m_u_p gem is also a good example of writing a fairly complex plugin for Mongrel that is easy to install. Take a look if you want to do similar fancy hackery. -- Zed A. Shaw http://www.zedshaw.com/ http://mongrel.rubyforge.org/ http://www.lingr.com/room/3yXhqKbfPy8 -- Come get help.
Kaspar Schiess
2006-Sep-12 09:15 UTC
[Mongrel] [ANN] Mongrel Upload Progress 0.2 -- With Instructions and Examples
Hello all, Is it just me or are the upload plugin instructions all buggy? I had to change the following bits of code: - FilesController#progress: #check is an instance method if the Singleton Mongrel::Uploads, so Uploads.instance.check instead of Uploads.check. def progress render :update do |page| @status = Mongrel::Uploads.instance.check(params[:upload_id]) page.upload_progress.update(@status[''size''], @status[''received'']) if @status end end - Progressbar would not show at first. I had to fix the javascript at least in one place: update: function(status, statusHTML) { this.statusText.innerHTML = statusHTML; + this.statusBar.style.width = '''' + Math.floor(this.statusBarWidth * status) + ''px''; - this.statusBar.style.width = Math.floor(this.statusBarWidth * status); } - Not a problem of the instructions per se, but worth mentioning: Lighttpd seems to buffer the whole upload and then send it all at once to a proxied mongrel instance behind it. So that won''t give you any progress bar at all. Pound as a frontend behaves much better. I hope to be of help with this tale of experience made. Really nice work on the plugin guys, thank you a lot. Zed, thanks for Mongrel, it has given me confidence about rails deployment for the first time - have tried all other magic bullets, and most of them didn''t quite work. best regards kaspar neotrivium.com - the swiss ruby shop
Rick Olson
2006-Sep-12 12:59 UTC
[Mongrel] [ANN] Mongrel Upload Progress 0.2 -- With Instructions and Examples
On 9/12/06, Kaspar Schiess <eule at space.ch> wrote:> Hello all, > > Is it just me or are the upload plugin instructions all buggy? I had to > change the following bits of code: > > - FilesController#progress: #check is an instance method if the > Singleton Mongrel::Uploads, so Uploads.instance.check instead of > Uploads.check. > > def progress > render :update do |page| > @status = Mongrel::Uploads.instance.check(params[:upload_id]) > page.upload_progress.update(@status[''size''], @status[''received'']) > if @status > end > end > > - Progressbar would not show at first. I had to fix the javascript at > least in one place: > > update: function(status, statusHTML) { > this.statusText.innerHTML = statusHTML; > + this.statusBar.style.width = '''' + Math.floor(this.statusBarWidth > * status) + ''px''; > - this.statusBar.style.width = Math.floor(this.statusBarWidth * > status); > } > > - Not a problem of the instructions per se, but worth mentioning: > Lighttpd seems to buffer the whole upload and then send it all at once > to a proxied mongrel instance behind it. So that won''t give you any > progress bar at all. Pound as a frontend behaves much better. > > I hope to be of help with this tale of experience made. Really nice work > on the plugin guys, thank you a lot. Zed, thanks for Mongrel, it has > given me confidence about rails deployment for the first time - have > tried all other magic bullets, and most of them didn''t quite work. > > best regards > kaspar > > neotrivium.com - the swiss ruby shopI don''t know, I made that video with that exact code. -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.com
Zed Shaw
2006-Sep-12 13:10 UTC
[Mongrel] [ANN] Mongrel Upload Progress 0.2 -- With Instructions and Examples
On Tue, 2006-09-12 at 11:15 +0200, Kaspar Schiess wrote:> Hello all, > > Is it just me or are the upload plugin instructions all buggy? I had to > change the following bits of code: > > - FilesController#progress: #check is an instance method if the > Singleton Mongrel::Uploads, so Uploads.instance.check instead of > Uploads.check. >You sure you''re using the right version? You need the stuff available currently from the pre-release. So, if you didn''t do: gem install mongrel mongrel_upload_progress --source=http://mongrel.rubyforge.org/releases/ Then you''ve got the wrong one.> - Not a problem of the instructions per se, but worth mentioning: > Lighttpd seems to buffer the whole upload and then send it all at once > to a proxied mongrel instance behind it. So that won''t give you any > progress bar at all. Pound as a frontend behaves much better. >Interesting to know. I know Rick uses litespeed so I''m curious what he gets.> I hope to be of help with this tale of experience made. Really nice work > on the plugin guys, thank you a lot. Zed, thanks for Mongrel, it has > given me confidence about rails deployment for the first time - have > tried all other magic bullets, and most of them didn''t quite work.Thanks Kaspar. Much appreciated. -- Zed A. Shaw http://www.zedshaw.com/ http://mongrel.rubyforge.org/ http://www.lingr.com/room/3yXhqKbfPy8 -- Come get help.