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 Install extra
urllib3 Urllib3Reader sync (included)
httpx2 Httpx2SyncReader sync httpx2
httpx2 Httpx2AsyncReader async httpx2
requests RequestsReader sync requests
aiohttp AiohttpReader async 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.0.1.tar.gz (142.1 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.0.1-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for zipwire-0.0.1.tar.gz
Algorithm Hash digest
SHA256 1f04c9c26c57de25a8af4f5336cd477d609f456c56165b6c451c74b8d743668b
MD5 f816dccdf0ffc1849fd1a3e53ab42a05
BLAKE2b-256 b4832c744091c861819812ac8888462dbb70a64ad8d01be6e71885548e5de23b

See more details on using hashes here.

Provenance

The following attestation bundles were made for zipwire-0.0.1.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.0.1-py3-none-any.whl.

File metadata

  • Download URL: zipwire-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 24.8 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.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ce203fb113292df48b68e2d72586405699842662bcca322326eab9b39929f376
MD5 2f87bf9e78a44e0da2d6876c19418df6
BLAKE2b-256 f161cba251b8e0ba6dfc56713950483e84c2ea8604f9d2bd504fb39b0be9e735

See more details on using hashes here.

Provenance

The following attestation bundles were made for zipwire-0.0.1-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