If you do not mind reading the entire zip file in memory, the fastest way to read and write it is:
data = f.readlines() with open(localFile,'wb') as output: output.writelines(data)
Otherwise, to read and write in pieces as they are received over the network, do
with open(localFile, "wb") as output: chunk = f.read() while chunk: output.write(chunk) chunk = f.read()
This is a little less neat, but does not allow you to immediately save the entire file in memory. Hope this helps.
James
source share