Skip to content

Commit cc61658

Browse files
author
SpiderOak
committed
initial commit
0 parents  commit cc61658

5 files changed

Lines changed: 1181 additions & 0 deletions

File tree

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
*.py[cod]
2+
3+
# C extensions
4+
*.so
5+
6+
# Packages
7+
*.egg
8+
*.egg-info
9+
dist
10+
build
11+
eggs
12+
parts
13+
bin
14+
var
15+
sdist
16+
develop-eggs
17+
.installed.cfg
18+
lib
19+
lib64
20+
__pycache__
21+
22+
# Installer logs
23+
pip-log.txt
24+
25+
# Unit test / coverage reports
26+
.coverage
27+
.tox
28+
nosetests.xml
29+
30+
# Translations
31+
*.mo
32+
33+
# Mr Developer
34+
.mr.developer.cfg
35+
.project
36+
.pydevproject

README.markdown

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
# ZipStream
3+
4+
zipstream.py is a zip archive generator based on zipfile.py. It was created to
5+
generate a zip file on-the-fly for download in a web.py (http://webpy.org/)
6+
application. This is beneficial for when you want to provide a downloadable
7+
archive of a large collection of regular files, which would be infeasible to
8+
generate the archive prior to downloading.
9+
10+
The archive is generated as an iterator of strings, which, when joined, form
11+
the zip archive. For example, the following code snippet would write a zip
12+
archive containing files from 'path' to a normal file:
13+
14+
```python
15+
zf = open('zipfile.zip', 'wb')
16+
for data in ZipStream(path):
17+
zf.write(data)
18+
zf.close()
19+
```
20+
21+
Since recent versions of web.py support returning iterators of strings to be
22+
sent to the browser, to download a dynamically generated archive, you could
23+
use something like this snippet:
24+
25+
```python
26+
def GET(self):
27+
path = '/path/to/dir/of/files'
28+
zip_filename = 'files.zip'
29+
web.header('Content-type' , 'application/zip')
30+
web.header('Content-Disposition', 'attachment; filename="%s"' % (
31+
zip_filename,))
32+
return ZipStream(path)
33+
```
34+
35+
If the zlib module is available, ZipStream can generate compressed zip
36+
archives.
37+
38+
## Requirements
39+
40+
* Python >=2.6
41+
42+
## License
43+
44+
This library was created by SpiderOak, Inc. and is released under the GPLv3.
45+
Copyright 2008-2013 SpiderOak Inc.
46+

0 commit comments

Comments
 (0)