ryah ([info]four) wrote,
@ 2007-07-08 03:04:00
Previous Entry  Add to memories!  Tell a Friend!  Next Entry
Entry tags:projects, upload progress bar

mongrel_streaming_upload_progress-0.2
I made a little javascript class (which depends on prototype.js) that can interpret a stream of JSON objects separated by semicolons.

As an application of this, this Mongrel plug-in streams upload status when given a qualified upload_id. It looks like this:

{"received":5939792,"status":200,"state":"uploading","size":36872784};
{"received":6398544,"status":200,"state":"uploading","size":36872784};
[...]
{"received":36479568,"status":200,"state":"uploading","size":36872784};
{"received":36856400,"status":200,"state":"uploading","size":36872784};
{"received":36872784,"status":200,"state":"done","size":36872784};
(The format of these JSON objects is the same that is being used in the upload progress plug-in for Lighttpd 1.5 as described here)

Included with this package is the javascript class Ajax.Pull and an example Rails application.

mongrel_streaming_upload_progress-0.2.gem
mongrel_streaming_upload_progress-0.2.tgz

This should work with Safari 3 and Firefox. I haven't tested IE. When I get around to it will add a hack to Ajax.Pull which falls back on polling a URL for the JSON updates if the browser does not support Ajax streaming. This plug-in already supports this sort of polling with the ?single URL parameter.

cross posted here and here



Create an Account
Forgot your login?
Login w/ OpenID
English • Español • Deutsch • Русский…