0

My app has a zipped file stored in internet and my app download it when it is first runned.

In a good internet connection, everything works fine. However, when internet is not good, file is downloaded but it is corrupted.

How can I avoid this?

Any help will be appreciatted.

Thanks!

Carlos Pereira
  • 1,914
  • 6
  • 24
  • 35

1 Answers1

0

I don't think that there is a way to restore the corrupted data, but if the ZIP-file isn't very large, you could check the MD5-checksum of the original file, and the (potentially) corrupted ZIP you've downloaded. If the checksums match, everything is okay, if not, download it again.

  • Thank you for your answer, however, I mean, my intention is not to restore corrupted data. My intention is: when downloading, just download if it's really okay to download... even if it takes longer... what you are saying to me is that user must wait until it's over and then, when it's over, I test it and I tell him download is corrupted. Is there another way? I mean, a way to ensure that downloaded data is only saved if it's okay? – Carlos Pereira Jun 19 '13 at 00:33
  • No, I actually meant that you could redownload it if it was corrupted. (In a Script, without user-action). This is easy to check using the MD5-checksums of the actual file and the file you've downloaded. So, the workflow would be like: Download ZIP. Check if ZIP is okay via MD5. If not, redownload it (automatically), check MD5 again. (this maximum 5 times in a row. If it really fails 5 times in a row it must be a really crappy internet connection...) If a download worked there is no problem anyway :) –  Jun 19 '13 at 10:16