Skip to main content

Read and extract files from remote ZIP archives over HTTP range requests

Project description

zipwire

Extract individual files from remote ZIP archives over HTTP - without downloading the whole thing.

A zip wire gets you straight to your destination. This library does the same: it uses HTTP range requests to fetch only the central directory and the specific entries you ask for, skipping everything else. A 10 KB file inside a 2 GB archive? zipwire downloads roughly 10 KB (plus a small overhead for the central directory), not 2 GB.

How it works

ZIP archives store a central directory at the end of the file that lists every entry with its offset and size. zipwire fetches that directory first (a single range request), then makes one additional range request per file you extract. The server must support Range requests (Accept-Ranges: bytes), which most CDNs, object stores, and static file servers do.

Key features

  • Selective extraction - download only the files you need, not the entire archive.
  • Streaming decompression - read_into decompresses in chunks, keeping memory usage low even for large entries.
  • Sync and async - SyncRemoteZip for synchronous code, AsyncRemoteZip with await/async with for asyncio.
  • ZIP64 - supports archives and entries larger than 4 GiB.
  • Pluggable backends - bring your own HTTP library (see below).

Installation and backends

The default installation includes the urllib3 backend. To use a different HTTP library, install the matching extra - for example httpx2 gives you both sync and async:

pip install zipwire[httpx2]
Backend Class Mode HTTP Install extra
urllib3 Urllib3Reader sync 1.1 (included)
httpx2 Httpx2SyncReader sync 1.1, 2 httpx2
httpx2 Httpx2AsyncReader async 1.1, 2 httpx2
requests RequestsReader sync 1.1 requests
aiohttp AiohttpReader async 1.1 aiohttp

Every backend accepts an optional pre-configured client or session so you can share connection pools, authentication, and retry configuration.

Examples

Sync - list files and read one

from zipwire import SyncRemoteZip
from zipwire.backends import Urllib3Reader

reader = Urllib3Reader("https://archive.example/data.zip")
with SyncRemoteZip(reader) as rz:
    for info in rz.infolist():
        print(f"{info.filename}  {info.file_size} bytes")

    data = rz.read("path/to/file.txt")

Sync - stream a large file to disk

read_into decompresses in chunks so peak memory stays low:

from zipwire import SyncRemoteZip
from zipwire.backends import Urllib3Reader

reader = Urllib3Reader("https://archive.example/large.zip")
with SyncRemoteZip(reader) as rz:
    with open("output.bin", "wb") as f:
        rz.read_into("big-file.bin", f)

Async

import asyncio
from zipwire import AsyncRemoteZip
from zipwire.backends import AiohttpReader

async def main():
    reader = AiohttpReader("https://archive.example/data.zip")
    async with AsyncRemoteZip(reader) as rz:
        data = await rz.read("path/to/file.txt")
        print(data.decode())

asyncio.run(main())

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zipwire-0.1.0.tar.gz (154.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zipwire-0.1.0-py3-none-any.whl (27.9 kB view details)

Uploaded Python 3

File details

Details for the file zipwire-0.1.0.tar.gz.

File metadata

  • Download URL: zipwire-0.1.0.tar.gz
  • Upload date:
  • Size: 154.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for zipwire-0.1.0.tar.gz
Algorithm Hash digest
SHA256 92fc01a1dd83c1b64a87b103b1a7df033f50c996123b99fc59ecab94503b9a8f
MD5 5e5bafbccaac59d18343ab6e9931b34f
BLAKE2b-256 9b6ad595060a86b53d1051998e60f33d1c4c3e68458d353311f1559e621513c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for zipwire-0.1.0.tar.gz:

Publisher: release.yml on tiran/zipwire

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file zipwire-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: zipwire-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 27.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for zipwire-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f69b34258eb515d072e1943f73dbe687af73ec6f7476e2adcc781bb0fd22c32e
MD5 227acb1869dfa7a007c1ef6cf189d32c
BLAKE2b-256 1b37a818e4e362d079c3aa6f9c81ee0327754f91b1bfda9a234fbe12e244e5b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for zipwire-0.1.0-py3-none-any.whl:

Publisher: release.yml on tiran/zipwire

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page