2015-06-16, 17:56
Hi everyone,
I have this code
I am using a raspberry pi b+ the problem with this code is, if I'm not mistaken, is that it will download the whole file to ram and then write to disk. if the ram is not big enough it will fail. I have read somewhere that the file can be broken into chunks and written to disk without filling the ram up, crashing the pi.
Can someone please help with how to do this. Thanks in advance.
I have this code
Code:
import urllib2
url = 'http://www.mywebsite.com/my.zip'
f = urllib2.urlopen(url)
data = f.read()
with open("my/location/code2.zip", "wb") as code:
code.write(data)
I am using a raspberry pi b+ the problem with this code is, if I'm not mistaken, is that it will download the whole file to ram and then write to disk. if the ram is not big enough it will fail. I have read somewhere that the file can be broken into chunks and written to disk without filling the ram up, crashing the pi.
Can someone please help with how to do this. Thanks in advance.