I want to add an image in a directory under a zip. The structure of the zip is the following:
doc1.zip
├── word
| ├── media
| ├── img1.png
| └── img2.png
I want to add the picture soc_logo
under media.
I wrote the following code:
with zipfile.ZipFile(zip_copy_filename, "w") as documentx:
for filename in filenames:
if filename=='word/media/soc_logo.png':
documentx.write(os.path.join(tmp_dir,filename))
else:
documentx.write(os.path.join(tmp_dir,filename), filename)
But the result is the following:
doc1.zip
├── temp
| ├── /tmpT6kmaW/word/media/
├── word
| ├── media
| ├── img1.png
| └── img2.png
Any help please ?