Created
October 27, 2011 15:18
-
-
Save tanelpuhu/1319851 to your computer and use it in GitHub Desktop.
kolm faili ühte... umbes nii?
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
self.response.headers['Content-Type'] = 'application/zip' | |
self.response.headers['Content-Disposition'] = 'attachment; filename="example.zip"' | |
self.response.headers['Content-Length'] = len(text) | |
self.response.headers['Content-Transfer-Encoding'] = 'binary' | |
self.response.out.write(text) |
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
#!/usr/bin/env python | |
"zip" | |
from StringIO import StringIO | |
from zipfile import ZipFile | |
zio = StringIO() | |
zipper = ZipFile(zio, 'w') | |
zipper.writestr('file_1.txt', '1') | |
zipper.writestr('file_2.txt', '22') | |
zipper.writestr('file_3.txt', '333') | |
zipper.close() | |
fl = open('files.zip','wb') | |
fl.write(zio.getvalue()) | |
fl.close() | |
zio.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment