Created
May 1, 2011 20:44
-
-
Save mdornseif/950860 to your computer and use it in GitHub Desktop.
This is shows how to generate ZIP files in the blobstore.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def store_pdfs_in_zip(): | |
docs = Dokument.all().order('updated_at') | |
file_name = files.blobstore.create(mime_type='application/zip', | |
_blobinfo_uploaded_filename='test.zip') | |
with files.open(file_name, 'w') as f: | |
z = blobstoreZipFile(f) | |
for doc in docs.fetch(75): | |
pdf = doc.data | |
fname = "%s-%s.pdf" % (doc.designator, doc.updated_at) | |
fname = fname.encode('ascii', 'replace') | |
z.writestr(fname, pdf, date_time=doc.updated_at.timetuple()[:6]) | |
# Finalize ZIP file and write directory | |
z.flush() | |
# Finalize the file in the blobstore | |
files.finalize(file_name) | |
# Get the file's blob key | |
blob_key = files.blobstore.get_blob_key(file_name) |
Do you mean the file generated is bzip2 compressed?
The code I currently use is in https://gist.github.com/950846#file_replication.py
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@carlopires I tested it and then moved to
tar.bz2
. Did you check the actual contents of the file?