Adding a file-like object to a Zip file in Python
You are correct, those are the only two choices. If your DefaultStorage
object is large, you may want to go with saving it to disk first; otherwise, I would use:
zipped = ZipFile(...)
zipped.writestr('archive_name', default_storage_object.read())
If default_storage_object
is a StringIO
object, it can use default_storage_object.getvalue()
.