Is it possible to create files in memory, and arrange them in a type of hierarchy before writing them to disk?
Can an open statement be redirected into some kind of in-memory representation?
My current technique for creating the zipped directories is this:
- Write everything in memory to a temporary folder
- Create a
zipfileobject - reload all of the previously made files
- Add them to the zip and save
- Delete all the temporary files.
Ultimately ending up with something like this:
Zipped_root
|
|
|---- file1.txt
|
|---- Image1.png
|
|---- Image2.png
|
|---- file...N.txt
|
Is there a way to do this all in memory?
PILobject with theStingIOmodule, and then pass that to thewritestrfunction of the zipfile library. Works like a charm now! Thanks!