Package which allows you to take several file streams and turn them into a single zipfile stream
Project description
StreamZipper
This package allows you to collect several streams of files and then turn several streams into one single zipped stream
This can be usefull if you want to serve multiple files from a file server as a single zip file. but you dont to load all files in memory
installation
pip install stream-zipper
Usage
from stream_zipper import ZipStream
zip_stream = ZipStream()
zip_stream.prepare_stream(file_stream_1)
zip_stream.prepare_stream(file_stream_2)
zip_stream.prepare_stream(file_stream_3)
zipped_stream = zip_stream.stream()
the first argument is always the stream of the file. all other arguments must be passed as keyword argument (key=val)
in the method prepare_stream you can also specify the following kwargs :
- file_name: the name of the file (in the zip)
- zip_info: Can be used to pass a ZipInfo object. (makes other variables useless)
- file_size: size of the file, if set to 0 or not set then it will find the file_length for you
- crc: crc code of the file, if set to 0 or not set then it will find the crc for you
When you provide the crc or file_size it will check the provided value against the data it processed in the stream of that file If these values do not match then an exception will be thrown.
Notes
If you do not know the file_size or crc code then that file will have to be streamed twice to get these variables
if you do know the crc code of the files and you know the file_size then it will only call the stream once
it will check per file if it needs to get these values. so it is possible that only some files/streams have the crc and file_size variables.
from stream_zipper import ZipStream
zip_stream = ZipStream()
zip_stream.prepare_stream(file_stream_1) # no crc or file_size. calls the stream 2 times
zip_stream.prepare_stream(file_stream_2, file_size=100) # no crc calls the stream 2 times
zip_stream.prepare_stream(file_stream_3, crc="CRC-CODE") # no file_size calls the stream 2 times
zip_stream.prepare_stream(file_stream_4, file_size=100, crc="CRC-CODE") # both file_size and crc present will call stream 1 time
zipped_stream = zip_stream.stream() # total streams called 7
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file stream-zipper-1.0.1.tar.gz
.
File metadata
- Download URL: stream-zipper-1.0.1.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7077eac2337fb6686c93f16ab5d8f59111bd79b989d7d60ae2d8f2533ee273a1 |
|
MD5 | c5a959aa06880f71e37acdb280524683 |
|
BLAKE2b-256 | 41f5c42b1e4dc18c680de42ef7d87098a76cd8f6b01d9beb7233589dafdf6a70 |
File details
Details for the file stream_zipper-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: stream_zipper-1.0.1-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4702aa23043460d111eb260f9dc84c9a2f994c2b4f6baddfe3646be215d4b7c2 |
|
MD5 | f517303f892c3fc27950ef944da6e3fe |
|
BLAKE2b-256 | 20cea9ef93b14e9d0efbe5b973a1e6d4aba77fc9bb38aa30e68b70e4829ab73f |