I’m using AppEngine to store some pickled python objects in my app. I want to serve these to the user directly, and I’m simply using the X-AppEngine-Blobkey header to serve the files to the user with a file.pickle.gz filename. However, when I try to extract these on my computer (Mac OS) using a simple double click, the files are turned into file.pickle.gz.cpgz.
I thought it was my browser being sneaky and extracting them, but I don’t think so, since
pickle.load('file.pickle.gz')
Doesn’t work, and neither does
pickle.load('file.pickle.gz.cpgz')
To store the files, I use:
blobfile = files.blobstore.create(mime_type='application/gzip')
with files.open(blobfile, 'a') as f:
gz = gzip.GzipFile(fileobj=f,mode='wb')
gz.write(my_pickled_object)
gz.close()
files.finalize(blobfile)
I think I’m not understanding the way gzips work. Can someone explain?
Are you sure
file.pickle.gz.cpgzis the result of your double-clicking on thefile.pickle.gzfile you downloaded? Usually “.cpgz” is a different kind of archive file.I can get the code you posted to work in a development server without significant changes. Here’s the code, if it helps:
Click on “make”, then click on “get”. A file named “get.gz” is downloaded to your
~/Downloads/folder (at least in Chrome). Double-click on it to produce a file named “get”. Then: