views:

629

answers:

1

I am looking for a pure Javascript/Python upload example, that uses server polling instead of client-side SWF to display upload progress (like the one on rapidshare.com for example)

Currently, website is running on the standalone wsgi server included with Werkzeug framework, but may be moved to mod_wsgi if the load increases.

I've tried the gp.fileupload middleware, but can't get it to work. Examples on their website wont work either :|

Website already uses Glow library for other misc client-side stuff, but there is no specific upload-related functionality in it.

A: 

If you don't have support on the web side to track the size of the temporary file (or in-memory buffer) of the uploading data as it arrives, I don't know how you'll do this. Some of the popular web servers have special support for this, mostly experimental, but it's not widely supported and what you're trying to do is pretty awkward in general. I've researched this recently and it's pretty poorly supported all around.

Peter Hansen
So, this cannot be implemented via a special kind of WSGI middleware?Or the request is buffered fully before going to the WSGI chain?
wizzard0
Basically the latter, in most cases and, as near as I can tell, in your specific case. Check werkzeug.http.parse_multipart(), where it ends with a call to file.exhaust() and the comment "# make sure the whole input stream is read". It's typical for web servers (e.g. nginx used to reverse proxy to your own app) to do similar things, buffering input fully before even calling you. It's easy to conceive how to do this differently, but I'm not yet aware of a server that has the right hooks, in Python. (There probably is one... I'm just not aware of it yet.)
Peter Hansen