Upload of binary files
Peter Hansen
peter at engcorp.com
Thu Mar 13 10:28:25 EST 2003
Irmen de Jong wrote:
>
> Peter Mott wrote:
> > if form.has_key("Data"):
> > fileinfo=form["Data"]
> > data = fileinfo.file.read()
>
> This won't do. It is not guaranteed that a single read() returns
> all of your data.
Since when? I know with sockets you don't get a guarantee that
recv() gets all the data, but the docs on read() for a file
object say:
read ([size])
Read at most size bytes from the file (less if the read hits EOF before
obtaining size bytes). If the size argument is negative or omitted,
read all data until EOF is reached.
That reads like a guarantee to me. Do I have to go and wrap all
our code that uses read() with a retry loop?
-Peter
More information about the Python-list
mailing list