Binary / SOAPpy
Tim Golden
mail at timgolden.me.uk
Fri Jun 8 16:24:35 EDT 2007
Robert Rawlins - Think Blue wrote:
> I have a WebService call which returns an array, the first element in
> that array is the binary for a zip file, however I’m having trouble
> writing that binary string into an actual file when it arrives, I’ve
> tried the following method.
>
> Result = call to the webservice that returns the array.
> file = open("Zips/1.zip", "wb")
> file.write(result[0])
> file.close()
>
> But this throws the error message:
>
> file.write(result[0])
>
> TypeError: argument 1 must be string or read-only buffer, not instance
Robert, do the obvious here, and insert:
print type (result[0])
print repr (result[0])
after you receive the result and before you open the file.
Is result[0] really what you expected?
By the way, you can't simply throw a zipped string into
a .zip file. The .zip file needs headers and so forth.
Maybe that's not quite what you're trying to do, but
it looks like it.
TJG
More information about the Python-list
mailing list