Upload of binary files
Irmen de Jong
irmen at -NOSPAM-REMOVE-THIS-xs4all.nl
Thu Mar 13 23:10:33 CET 2003
Peter Hansen wrote:
>>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.
I *may* indeed be wrong here, but consider this:
I was thinking.. "from your CGI code you're actually reading from
a socket, that's wrapped in a file-like object".
Sockets behave like I said. So I thought: the read() behaves like this too.
Even more so because there is no such thing as "EOF" on sockets.
How can the read() know when all data have been read?
PS a read() on a *true* file would read everything, ofcourse, like
you pointed out.
More information about the Python-list