Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,26 @@ def GET(self):
return zipstream.ZipFile(path)
```

### web2py
```python
def zipball():
import zipstream
import os
p = 'path/to/files'
z = zipstream.ZipFile(mode='w', compression=ZIP_DEFLATED)
for fname in os.listdir(p):
fp = os.path.join(p,fname)
z.write(fp, fname)

headers = {}
headers['Content-Type'] = 'application/zip'
headers['Content-Disposition'] = 'attachment; filename="files.zip"'
def zipped_stream():
for chunk in z:
yield chunk
raise HTTP(200, zipped_stream(), **headers)
```

## Running tests

With python version > 2.6, just run the following command: `python -m unittest discover`
Expand Down