python - Zip a set of blobs from appengine datastore -


i need zip set of blobs available in data store. these can of different types html/images/swf/ etc. these available in datastore blob.

i tried implement solution: zipping dynamic files in app engine (python)?

tried static texts worked great, able create zip set of files respective content not trace out issue when making zip query.

z.writestr(fil.template_name, my_data.encode('utf-8')) file "c:\python25\lib\zipfile.py", line 626, in writestr self.fp.write(zinfo.fileheader()) file "c:\python25\lib\zipfile.py", line 260, in fileheader return header + self.filename + unicodedecodeerror: 'ascii' codec can't decode byte 0xde in position 12: ordinal not in range(128) 

this error part of code

       class filesdb(db.model)                     template_file = db.blobproperty()                    template_name= db.stringproperty()          output = stringio.stringio()        z = zipfile.zipfile(output,'w')        files =  filesdb.all().filter("fcreatedby","sandeep")        fil in files:         my_data = fil.template_file         z.writestr(fil.template_name, my_data)         z.close() 

per zipfile documentation:

there no official file name encoding zip files.
if have unicode file names, must convert them byte strings in desired encoding before passing them write().

try encode filename in utf-8 example with:

class filesdb(db.model)                     template_file = db.blobproperty()                    template_name= db.stringproperty()          output = stringio.stringio()        z = zipfile.zipfile(output,'w')        files =  filesdb.all().filter("fcreatedby","sandeep")        fil in files:         my_data = fil.template_file         z.writestr(fil.template_name.encode('utf-8'), my_data)         z.close() 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -