1

I am trying to download a zip file from the cloud storage in the following manner:


import shutil 

  with tempfile.NamedTemporaryFile(suffix=".zip") as source_zip:
    aws_util.download(my_buicket, "my_folder/design.zip", source_zip)
    shutil.unpack_archive(source_zip.name, "myfile", "zip")

While trying to unpack the temporary zip file created in the step above. I am getting the following error:

shutil.ReadError: C:\Users\ryan.zhu\AppData\Local\Temp\tmppnn80v56.zip is not a zip file

I am using windows OS.

How to solve it. Thanks

zsh_18
  • 1,012
  • 1
  • 11
  • 29
  • 1
    You probably want to `source_zip.flush()` right after downloading, as the contents are probably yet to be written to disk. – Marco Bonelli Jun 10 '22 at 01:45

1 Answers1

-2

It is possible, that given file does not even exist and given error message is only making you think, that given file is somehow wrong.

Lubo
  • 1,621
  • 14
  • 33