How do you convert a string obj to a file obj?
Esben Pedersen
n.20.e5ke at spamgourmet.com
Wed May 4 13:56:31 EDT 2005
Matthew Thorley wrote:
> I'm writing a web app whereby a user uploads a tar acrhive which is then
> opened and processed. My web form reads the file like this:
>
> while 1:
> data = value.file.read(1024 * 8) # Read blocks of 8KB at a time
> if not data: break
>
> which leaves me with data as a string obj. The problem that I have is
> that the function that processes the archive expects a file object. So
> far the only solution I have found it to write the file to disk and then
> read it back.
>
> Is there an easy way to convert data, in the example above into a file
> object?
>
> Thanks
> -Matthew
value.file is a file object. Why don't you give that as an argument?
/Esben
More information about the Python-list
mailing list