https://github.com/doctorjohn/aiohttp-zip-response
A AIOHTTP response class streaming the contents of a directory as a ZIP archive - without storing the entire ZIP in memory or disk
https://github.com/doctorjohn/aiohttp-zip-response
aiohttp asyncio python python3 streaming zip
Last synced: 4 months ago
JSON representation
A AIOHTTP response class streaming the contents of a directory as a ZIP archive - without storing the entire ZIP in memory or disk
- Host: GitHub
- URL: https://github.com/doctorjohn/aiohttp-zip-response
- Owner: DoctorJohn
- License: mit
- Created: 2024-05-16T04:46:57.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2026-01-16T20:50:05.000Z (5 months ago)
- Last Synced: 2026-01-17T04:48:59.122Z (5 months ago)
- Topics: aiohttp, asyncio, python, python3, streaming, zip
- Language: Python
- Homepage:
- Size: 622 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# AIOHTTP ZIP Response
[![Versions][versions-image]][versions-url]
[![PyPI][pypi-image]][pypi-url]
[![Codecov][codecov-image]][codecov-url]
[![License][license-image]][license-url]
[versions-image]: https://img.shields.io/pypi/pyversions/aiohttp-zip-response
[versions-url]: https://github.com/DoctorJohn/aiohttp-zip-response/blob/main/pyproject.toml
[pypi-image]: https://img.shields.io/pypi/v/aiohttp-zip-response
[pypi-url]: https://pypi.org/project/aiohttp-zip-response/
[codecov-image]: https://codecov.io/gh/DoctorJohn/aiohttp-zip-response/branch/main/graph/badge.svg
[codecov-url]: https://codecov.io/gh/DoctorJohn/aiohttp-zip-response
[license-image]: https://img.shields.io/pypi/l/aiohttp-zip-response
[license-url]: https://github.com/DoctorJohn/aiohttp-zip-response/blob/main/LICENSE
A AIOHTTP response class streaming the contents of a directory as a ZIP archive.
Thanks to [stream-zip](https://github.com/uktrade/stream-zip/), this works **without storing the entire ZIP in memory or disk**.
Generally, this package is meant to complement the existing `aiohttp.web.FileResponse` class which can be used to stream the contents of a single file.
## Installation
```bash
pip install aiohttp-zip-response
```
## Usage
```python
from aiohttp import web
from aiohttp_zip_response import ZipResponse
async def handle_zip(request):
return ZipResponse('path/to/directory')
app = web.Application()
app.router.add_get('/zip', handle_zip)
web.run_app(app)
```
## Caveats
- The `Content-Length` header is not set because the size of the ZIP archive is not known in advance. This means clients such as browsers cannot display a download progress bar.
- This package currently doesn't support streaming of symbolic links to directories.