0

I tried to zip a folder with 50 GB worth of data (images and documents) on windows system but it resulted as a 50 GB zip archive that has type application/octet-stream. It's too late when I discover the issue since I have deleted the source data.

I was wondering if there is a way to recover the data programatically?

file output

I tried printing the content but had no luck so far ... `

>>> import zipfile
>>> with zipfile.ZipFile("backup.zip", "r") as f:
...     for file in zf.namelist():
...         print(file)
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/zipfile.py", line 1131, in __init__
    self._RealGetContents()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/zipfile.py", line 1198, in _RealGetContents
    raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file

`

  • Looking at the error message, it seems that the file isn't a valid zip file. How exactly did you compress the data? You could try data recovery tools, to restore deleted (but not overwritten data) if nothing else works – oleksii Oct 28 '22 at 01:14
  • @oleksii in this post the author managed to post and download the octet-stream file as zip. Do you think this will work? – user19192927 Oct 28 '22 at 02:55
  • 1
    Did you forget to include the link to the other post? Can you post a hex dump of a few hundred bytes from the zip file please? Don't post it screenshot -- we need to cut/paste the data to understand what is in the file. – pmqs Oct 28 '22 at 04:27
  • Hi @oleksii, sorry here's the link : https://stackoverflow.com/questions/55185449/post-produces-correct-zip-archive-from-octet-stream-through-postman-but-inval – user19192927 Oct 28 '22 at 18:54
  • Hi @pmqs sorry here's the link : https://stackoverflow.com/questions/55185449/post-produces-correct-zip-archive-from-octet-stream-through-postman-but-inval – user19192927 Oct 28 '22 at 18:54
  • Without knowing more about the how you actually created you zip file it is impossible to say. Does the link actually match you used to create the created your zip file? Please update the original question detailing how exactly your zip file was created and if it has been retrieved from a server in a corrupt state. Also, we _really_ need to see a hexdump of the start of the file. Something like this should get it for you `head -c 100 backup.zip | hexdump -V` – pmqs Oct 28 '22 at 19:49
  • hi @pmqs i created the zip file by clicking right -> add to archive in windows 10 64 bit system i suspect the process terminated prematurely but my source folder has ~50 GB of data (approx. same as the corrupt zip) so i hoping to recover what ever is possible. It is already in corrupt state on windows so I decided to give it a try on my MAC book pro. For some reason my hexdump does not support -V so I ran the following instead. Here is the output of the hexdump command : % hexdump -n500 backup.zip 0000000 0000 0000 0000 0000 0000 0000 0000 0000 * 00001f0 0000 0000 00001f4 – user19192927 Oct 28 '22 at 19:59
  • 1
    Sorry - the hexdump command should have been `head -c 100 backup.zip | hexdump -C` , Regardless, if the zipping process was interrupted, you may be out of luck -- the output file may be in an indeterminate state. That hex dump certainly doesn't look like anything like the start of a valid zip file. Also, the link isn't relevant. Only other thing I can suggest is running zip recovery with `zip -FF backup.zip --out saved.zip`. If there is any zip data lurking, it should find it. – pmqs Oct 28 '22 at 20:53
  • @pmqs running the command produces an empty file. Do you have other suggestions? It it possible to fix the zip programatically? – user19192927 Oct 29 '22 at 03:21
  • Sorry, no. You are out of luck. – pmqs Oct 29 '22 at 09:52
  • there must be a way. think harder – user19192927 Oct 29 '22 at 15:36

0 Answers0