def download(self): q = Asset.query() assets = q.fetch(100) output = StringIO.StringIO() with zipfile.ZipFile(output, 'w') as zf: for a in assets: zf.writestr(a.fullpath.lstrip('/'), a.content) self.response.headers['Content-Type'] = 'application/zip' self.response.headers['Content-Disposition'] = 'attachment; filename="%s"' % 'site.zip' self.response.write(output.getvalue())
def download(self): q = Asset.query() assets = q.fetch(100) output = StringIO.StringIO() with zipfile.ZipFile(output, 'w') as zf: for a in assets: zf.writestr(a.fullpath.lstrip('/'), a.content) self.response.headers['Content-Type'] = 'application/zip' self.response.headers[ 'Content-Disposition'] = 'attachment; filename="%s"' % 'site.zip' self.response.write(output.getvalue())
def load_asset_content(fullpath): asset = Asset.query(Asset.fullpath == fullpath).fetch(1) if asset: return asset[0].content