While at it, why add .zip
to the list, so one may pack anything into download
Courtesy of a SO post:
zip_path = "test.zip"
my_zipfile = zipfile.ZipFile(zip_path, mode='w', compression=zipfile.ZIP_DEFLATED)
# Write to zip file
my_zipfile.write(excel_path)
my_zipfile.close()
with open(zip_path, "rb") as f:
bytes = f.read()
b64 = base64.b64encode(bytes).decode()
Similar as before, once we get the decoded b64
data, the remaining implementation is covered in @Marc example.