Skip to main content

Zip file streamer for HTTP

Similar systems/projects:

  • The Nginx zip module. Only for Nginx, so can’t be used with other webservers.

  • python-zipstream. Does not support calculating the file size beforehand or seeing through the file.

Usage:

import zipseeker

# Create an index
fp = zipseeker.ZipSeeker()
fp.add('some/file.txt')
fp.add('another/file.txt', 'file2.txt')

# Calculate the total file size, e.g. for the Content-Length HTTP header.
contentLength = fp.size()

# Calculate the last-modified date, e.g. for the Last-Modified HTTP header.
lastModified = fp.lastModified()

# Send the ZIP file to the client
# Optionally add the start and end parameters for range requests.
# Note that the ZIP format doesn't support actually skipping parts of the file,
# as it needs to calculate the CRC-32 of every file at the end of the file.
fp.writeStream(outputFile)

Why?

While the file size of a ZIP file usually can’t be calculated beforehand due to compression, this is actually optional. The headers itself also have a pretty constant size. That means that the whole file can have a predetermined file size (and modtime).

This is useful when you want to provide ZIP downloads of large directories with uncompressable files (e.g. images). The specific use case I created this media file for was to provide downloads of whole photo albums without such inconveniences as requesting a downloading link in an e-mail, using a lot system resources for the creation of temporary files, and having to delete these files afterwards.

Of course, it’s possible to just stream a ZIP file, but that won’t provide any progress indication for file downloads and certainly doesn’t support Range requests.

For more information, see the Nginx zip module.

TODO

  • Implement actual seeking in the file - this should be doable.

  • Use a CRC-32 cache that can be shared by the calling module.

Metadata

Release files for zipseeker 1.0.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zipseeker 1.0.11
File Size Uploaded
zipseeker-1.0.11.tar.gz 5.8 kB Details

Release files / zipseeker-1.0.11.tar.gz

Download URL zipseeker-1.0.11.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f0bc6b8dd5a66a8e09c98cb41ffeb31b83e2fc99d3f947afeda60c7605210e82
BLAKE2b-256 checksum
How to use checksums
352100435b5ea857c82ca47d305fbd569bb07d0f459100cdde8520eda2fd3139
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0.11 This release

1 release file

1.0.10

1 release file

1.0.9

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page