I am having a situation in ensuring that when I create a zip file it does not have the whole directory of the file when it is unzipped.
Having done some research there is a lot of content about using arcname
in zip.write
, however any solution I try results in the whole server being zipped!
I have tried adding arcname = os.path.basename(file)
and other possible solutions with no luck.
This is my code below:
all_order_files = glob.glob("/directory/"+str(order_submission.id)+"-*")
zip = zipfile.ZipFile("/directory/" + str(order_submission.id) + '-Order-Summary.zip', 'w')
for file in all_order_files:
zip.write(file)
zip.close()