I'm having trouble sifting through all the threads about uploading from a form and can't seem to find anything related to downloading and send from a URL.
I have a large gzipped json file that I need to download from an external server and process its results on App Engine. I have it working right now so that it is downloads the file into memory and unzips it, and then processes it into a task queue in small tasks. However, before making small code memory optimizations, I was hitting my 128MB limit on App Engine. I'm worried this is eventually going to happen again.
Here is my code just in case it is helpful to anyone else:
READ_BLOCK_SIZE = 1024*8
request = urllib2.Request(url)
response = urllib2.urlopen(request)
d = zlib.decompressobj(16+zlib.MAX_WBITS)
str = ""
while True:
data = response.read(READ_BLOCK_SIZE)
if not data:
break
data = d.decompress(data)
str += data
return str
Does anyone have any thoughts? Is there a good way to handle large files on App Engine and send them right to GCS so I don't have to hold it all in memory? Stream the download right to GCS somehow?