Reputation: 316
I have two servers: First server send some files to second server and then get the zip file. I need get this zip file from response. My first server:
files = {'file': ...}
ceb_response = requests.post(ceb, files=files)
My second server respond:
return HttpResponse(open('db.zip', 'rb'))
I need to save db.zip file in first server, how can I get the file from <Response [200]> and save file locally on first server?
Upvotes: 0
Views: 454
Reputation: 154
The response from your second server carry your zip file by byte[].
You can save the file in the 1st server like:
fileName = '/xxx/db.zip'
with open(fileName, 'wb') as f:
f.write(ceb_response.content)
Upvotes: 1
Reputation: 316
I found this answer:
import io, requests, pyzipper
r = requests.post(ceb + 'sync', files=files)
with pyzipper.AESZipFile(io.BytesIO(r.content)) as zf:
zf.setpassword(b'1111')
print(zf)
Upvotes: 0