Upload status tracking with Perlbal

Nov 05, 2005 00:09

How you can use Perlbal to give your users upload progress bars during browser uploads.... (which for some stupid reason have never shown progress bars....)

From:
http://lists.danga.com/pipermail/perlbal/2005-November/000138.html


In the latest version or two of Perlbal, Perlbal can now help you show a
progress bar to users during uploads.

Here's how you configure your Perlbal:

# Make a service that listens for UDP progress packets. With a single
# Perlbal, these packets are only from itself. Sorry, I didn't optimize
# for the single host case.

CREATE SERVICE uptrack
SET role = upload_tracker
SET listen = 127.0.0.1:7002
ENABLE uptrack

# Then configure your web_proxy service to send those packets once a
# second per connection (if the upload actually is requested being
# tracked)

CREATE SERVICE fotobilder
SET role = reverse_proxy
....
SET upload_status_listeners = 127.0.0.1:7002, 10.54.0.1:7001
...

Then use this JavaScript library:

http://cvs.danga.com/browse.cgi/wcmtools/js/perlbal-uploadtrack.js?rev=1.2

And on your page, use JavaScript to intercept the form submit event and
change the form's target to an in-page iframe and kick-off the library
doing its tracking (using XmlHttpRequest), calling your callback. (If the
client doesn't have javascript, your form submit goes through
unchanged...)

Here's an example:

Here's the patch I just did for fotobilder with almost that exact same code above:

http://www.livejournal.com/community/fotobilder_cvs/257401.html

Enjoy!

- Brad

javascript, tech, perlbal, work, perl

Previous post Next post
Up