Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^7: CRC Error on ZIP Files

by hazylife (Monk)
on Mar 12, 2014 at 16:36 UTC ( [id://1078047]=note: print w/replies, xml ) Need Help??


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

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); }

Replies are listed 'Best First'.
Re^8: CRC Error on ZIP Files
by SearchigPerl (Acolyte) on Mar 13, 2014 at 21:33 UTC
    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

        Is it the header section in which you expressively specify the length of file, that solved the issue ? If not: what was it ?
        I'm not sure myself, it's been a good ten years since I last had to deal with CGI. It should have worked without the content-length header, so - charset => 'binary' perhaps? Well, glad to hear it works now :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1078047]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-04-25 19:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found