[mod_python] finding length of user file before uploading

greg girty at cogeco.ca
Fri Apr 14 22:36:23 EDT 2006


I want a script (PSP preferred, custom handler if need be) that can
cancel an upload if the file is too large, or is taking too long.
The list archives have a few hacks for custom uploads using:

	util.FieldStorage(req, file_callback=FileFactory)

However, this parameter is not in the official docs, and several
previous posters noticed the behaviour breaking between versions.
My system is Debian, Apache2, mod_python 3.1.3-3.
When I try the file_callback trick, I get:

   File "/var/www/upload.psp", line 40, in ?
     frm = util.FieldStorage(req, file_callback=make_file)

TypeError: __init__() got an unexpected keyword argument 'file_callback'


I presume that undocumented feature has become extinct in recent versions.

And, even if it had worked, it still doesn't relay the size of the
file until the transfer is eating time and memory.
I would like to avoid making a custom handler that gets the data 
directly from the client--it seems like I would re-invent the wheel. A 
slower wheel.

What is the best way to aquire the filesize before the upload starts?

Thanks,

Greg



More information about the Mod_python mailing list