ZipFly
ZipFly is a zip archive generator based on zipfile.py. It was created to generate very large ZIP archives for immediate sending out to clients, or for writing large ZIP archives without memory inflation.
Requirements
Python 3.6+ Added support for writing to unseekable streams.
Install
pip3 install zipfly
Basic usage, compress on-the-fly during writes
Using this library will save you from having to write the Zip to disk. Some data will be buffered by the zipfile deflater, but memory inflation is going to be very constrained. Data will be written to destination by default at regular 32KB intervals.
ZipFly defaults attributes:
- paths: [ ]
- mode: (write) w
- chunksize: (bytes) 32768
- compression: Stored
- allowZip64: True
- compresslevel: None
- storesize: (bytes) 0
- encode: utf-8
paths list of dictionaries:
| . | |
|---|---|
| fs | Should be the path to a file on the filesystem |
| n (Optional) | Is the name which it will have within the archive (by default, this will be the same as fs) |
import zipfly
paths = [
{
'fs': '/path/to/large/file'
},
]
zfly = zipfly.ZipFly(paths = paths)
generator = zfly.generator()
print (generator)
# <generator object ZipFly.generator at 0x7f74d52bcc50>
with open("large.zip", "wb") as f:
for i in generator:
f.write(i)
Examples
Streaming multiple files in a zip with Django or Flask Send forth large files to clients with the most popular frameworks
Create paths Easy way to create the array
pathsfrom a parent folder.
Predict the size of the zip file before creating it Use the
BufferPredictionSizeto compute the correct size of the resulting archive before creating it.
Streaming a large file Efficient way to read a single very large binary file in python
Set a comment Your own comment in the zip file
Metadata
Release files for zipfly 6.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| zipfly-6.0.5.tar.gz | 8.2 kB | Without provenance | Details for zipfly-6.0.5.tar.gz |
Release files / zipfly-6.0.5.tar.gz
| Download URL | zipfly-6.0.5.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
93c56943dca4bf8a1d7de48a15ca9fa8310ade638f2e2493695853a48448efc0
|
|
BLAKE2b-256 checksum How to use checksums |
649e1a99b30e5e5c99d5f669c6118277d9f34c94a37e20baa2364fd8a15ed7b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.7
|
Security for zipfly 6.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.