[New-bugs-announce] [issue9968] Let cgi.FieldStorage have named uploaded file
report at bugs.python.org
Tue Sep 28 13:58:16 CEST 2010
New submission from phep <patrice.pillot at teletopie.net>:
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.
components: Extension Modules
title: Let cgi.FieldStorage have named uploaded file
type: feature request
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce