-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathREADME.txt
41 lines (32 loc) · 1.57 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
==============================================================================
This library was created by SpiderOak, Inc. and is released under the GPLv3.
https://spideroak.com/
==============================================================================
SpiderOak zipstream module
zipstream.py is a zip archive generator based on zipfile.py. It was created to
generate a zip file on-the-fly for download in a web.py (http://webpy.org/)
application. This is beneficial for when you want to provide a downloadable
archive of a large collection of regular files, which would be infeasible to
generate the archive prior to downloading.
The archive is generated as an iterator of strings, which, when joined, form
the zip archive. For example, the following code snippet would write a zip
archive containing files from 'path' to a normal file:
zf = open('zipfile.zip', 'wb')
for data in ZipStream(path):
zf.write(data)
zf.close()
Since recent versions of web.py support returning iterators of strings to be
sent to the browser, to download a dynamically generated archive, you could
use something like this snippet:
def GET(self):
path = '/path/to/dir/of/files'
zip_filename = 'files.zip'
web.header('Content-type' , 'application/zip')
web.header('Content-Disposition', 'attachment; filename="%s"' % (
zip_filename,))
return ZipStream(path)
If the zlib module is available, ZipStream can generate compressed zip
archives.
Contact the SpiderOak team at [email protected]
And be sure to back up your files! http://www.spideroak.com