Reputation: 25
I am writting a Python script that consumes a Web Service in order to access some xml file stored in a zipped folder with 3 other xml files: zipfolder/myxmlfile.xml
The Web Service provides a method "GetResponse" that can be used to get the zipped folder in the form of base64 data, as explained in the documentation.
So I use this method as the following:
response = client.service.GetResponse()
"response" if of class "bytes". Shouldn't it be base64 as described in the documentation?
How can I access my xml file using this variable which presumably contains the zip file data?
Your help is highly appreciated.
Upvotes: 0
Views: 951
Reputation: 25
When I checked my "response" data I found out it wasn't base64, so I Base64 encoded it, then I Base64 decoded it. Finally, I wrote to a zip file and it worked.
encoded = base64.b64encode(response)
decoded = base64.b64decode(encoded)
with open('myzipfile.zip', 'wb') as f:
f.write(decoded)
Upvotes: 0
Reputation: 3103
Try this using base64
:
import base64
bin = base64.b64decode(response)
with open('your_path/your_filename.zip', 'wb') as f:
f.write(bin)
Upvotes: 1