A
A
Andrey Bondarenko2018-02-11 16:37:39
Python
Andrey Bondarenko, 2018-02-11 16:37:39

How to create a ZipFile containing multiple "files"/BytesIO without intermediately writing them to disk?

i.e. it is required:

bin1 = BytesIO
bin2 = BytesIO
zip = ZipFile( 'my.zip')
zip.__APPEND__( 'file1.bin', bin1)
zip.__APPEND__( 'file2.bin', bin2)
zip.close()

The output is an archive:
my.zip:
  file1.bin
  file2.bin

I found only recipes with an intermediate recording of bin1 and bin2 in temporary files, followed by adding already "physical" files to the archive.
I wish there were fewer overheads.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question