刘凡 9ff4d1d109 add S3,archive,truncate | 2 年之前 | |
---|---|---|
.. | ||
.circleci | 2 年之前 | |
.github | 2 年之前 | |
dist | 2 年之前 | |
examples | 2 年之前 | |
zipfly | 2 年之前 | |
zipfly.egg-info | 2 年之前 | |
LICENSE | 2 年之前 | |
MANIFEST.in | 2 年之前 | |
README.md | 2 年之前 | |
setup.cfg | 2 年之前 | |
setup.py | 2 年之前 |
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.
Python 3.6+ Added support for writing to unseekable streams.
pip3 install zipfly
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
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) |
from zipfly import ZipFly
paths = [
{
'fs': '/path/to/large/file'
}
]
zfly = ZipFly(paths=paths)
with open("large.zip", "wb") as f:
for i in zfly.generator():
f.write(i)
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
paths
from a parent folder.Predict the size of the zip file before creating it Use the
BufferPredictionSize
to 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