in reply to Re^5: CRC Error on ZIP Files
in thread CRC Error on ZIP Files

Hi Hazylife,
I checked according to your suggestion. Results are :
whether "heimat" is getting called or not, doesn't make a difference.

when commenting out the eof check everything is running fine, as long as the
amount of data downloaded does not exceed the buffer's size, regardless whether
there are one to two files. The very moment the data is more than
the buffers size (again no matter whether due to the size of one file or due to
the number of files) I end up with a corrupted file amoung the files transported
The last file transported ( a jpeg) is showing only half of the original
Any clues ?

Replies are listed 'Best First'.
Re^7: CRC Error on ZIP Files
by hazylife (Monk) on Mar 12, 2014 at 16:36 UTC
    whether due to the size of one file or due to the number of files
    "the number of files" - as in "the number of files within the archive", right? Because download() only handles one file at a time.
    Any clues ?
    Come to think of it, this could be a server configuration issue (google "mod_gzip" OR "mod_deflate" zip corruption). What happens if you put a (preferably large) ZIP archive somewhere within the document root and download it using the direct link?

    Well, anyway, try this slightly modified version of download:

    sub download { my $filename = $_[0].$_[1]; use CGI; $html=new CGI; $| = 1; print $html->header( -type => 'application/zip', -charset => 'binary', -attachment => $_[1], -Content_length => -s $filename); open($peunter, "<", $filename); binmode($peunter); binmode STDOUT; while (read($peunter,$bytes,1024)) { print $bytes; } close($peunter); }
      Yes, as in "the number of files in the archive".
      I'll check the direct link and your code during the weekend, as I am
      currently traveling with limited bandwidth of my internet connection.

      Cheers

        Hi hazylife

        I am late again with my reply, I hope you do not get that wrong !
        Finally I had the occasion to insert your code and I can report happily
        that it's all working perfectly now ! Evrything gets downloaded properly
        just at the length of file as it should. Thanks a lot for your help !!

        Looking at your code, the more detailed header that you defined drew my attention.
        Is it the header section in which you expressively specify the length of file, that solved the issue ?
        If not: what was it ?

        In order to provide all relevant information, in case someone looks this up:
        I had to find out, that after everything was solved, at least some windows-machines
        Would react strangely when downloading the zipfile. Strangely here means
        that there was no error message, yet the zipfile was shown as empty
        when handled by the operating systems (windows 8) functions.
        Accessing the files with Winzip showed the files were not empty at all
        but winzip issued a warning message regarding the paths given in the
        Zipfile, starting with two leading dots. So I removed the paths from the
        Zipfile and everything is ok since then.

        Once again : thanks a lot

        Cheers