Intending to offer an answer to my own question here, I think it is better suited to what I was trying to do. This method does not really make a file (without a temporary file).
Since ZipFile extends and really represents a bunch of convenient methods in ZipCentralDirectory, you can work directly with ZipCentralDirectory instead of ZipFile. This will allow you to use I / O streams to create and write a zip file. Plus, using StringIO, and you can do this from a string:
Update:
It actually doesn't work at all. He will write a readable zip file, but ONLY the zip file "Table of Contents". All internal files are 0 in length. Digging further into the Zip implementation, it looks like it only stores metadata in a zip record in memory and returns to the main file to read the rest. Based on this, it seems that it is generally impossible to use the Zip implementation without writing to the file system.
Codingwithspike
source share