New submission from phep <patrice.pil...@teletopie.net>:

Hi,

Presently, in cgi.FieldStorage, uploaded file are accessible through a 
file-like object created by a call to tempfile.TemporaryFile(), probably in 
order to ensure the file is deleted when the process terminates.

The problem is that when one wants to save the data to some permanent location, 
one does not have other choice thant read() from this file descriptor then 
write() to the desired place, which means the file data shall be duplicated. 
This is greatly undesirable when the uploaded file is huge.

Replacing the call to tempfile.TemporaryFile() by a call to 
tempfile.NamedTemporaryFile() (available from 2.3) would have the following 
advantages :
1) no impact on existing code,
2) saving a file would be as simple as invoking 
os.link(fieldstorage['filenamefield'].file.name, "/some/path")
3) There would be no need to duplicate data anymore.

The sole real inconvenience of this change would be to update the documentation 
accordingly.

tia,

phep

----------
components: Extension Modules
messages: 117512
nosy: phep
priority: normal
severity: normal
status: open
title: Let cgi.FieldStorage have named uploaded file
type: feature request

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue9968>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to