[New-bugs-announce] [issue9968] Let cgi.FieldStorage have named uploaded file

phep report at bugs.python.org
Tue Sep 28 13:58:16 CEST 2010


New submission from phep <patrice.pillot at 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 <report at bugs.python.org>
<http://bugs.python.org/issue9968>
_______________________________________


More information about the New-bugs-announce mailing list