python - ZIP - Zipping Files Doesn't Actually ZIP The Files -


i have short method takes file path , list of filenames path parameters , supposed zip files 1 archive file. problem instead of zipping files, creates empty directory in archive each file trying zip. here's method:

 def zip(self, file_path, filename_list):          f = zipfile.zipfile(file_path + '_converted_zip_archive.zip', 'w')         filename in filename_list:             f.write(file_path, filename)          f.close() 

if call

zip('uploads/', ['test_1.txt', 'test_2.txt', 'test_3.txt']) 

i end archive file has following directories:

/test_1.txt/ /test_2.txt/ /test_3.txt/ 

what doing wrong i'm creating bunch of empty directories in zip file instead of zipping these text files?

you writing directory archive 3 times (with 3 different names). more explicit, writing following archive:

uploads/ test_1.txt uploads/ test_2.txt uploads/ test_3.txt 

do rather mean this?

def zip(self, file_path, filename_list):     f = zipfile.zipfile(file_path + '_converted_zip_archive.zip', 'w')     filename in filename_list:         f.write(file_path + filename, filename)  # note addition of filename here     f.close() 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -