SearchigPerl has asked for the wisdom of the Perl Monks concerning the following question:
Ladies and Gentlemen, you REALLY made my day !
Thanks to all contributors !
Here is the working codesniplet:
Sorting out the file structure exported in the zipfle downloaded, should be a matter of try and error...sub download { use CGI; $html=new CGI; #print $html->header(-type => 'application/octet-stream', -attachment +=> $_[1]); print $html->header(-type => 'application/zip', -attachment => $_[1]); + open($peunter, "<", $_[0].$_[1]); binmode($peunter); binmode STDOUT; while (read($peunter,$bytes,1024)) { unless (eof()) { chomp($bytes); } print $bytes; } #@data = <$peunter>; close($peunter); #print "@data"; }
I am offering some files to download. In order to transport them all together in one leap my idea was to pack them in a zip-file, using archive::zip. Everything seems to be working just fine (no warnings, no errors, nothing) untill I try to open the zip file after the download. All programs on all platforms tested (Windows 7, 8, Mac OSX maverick) report a crc error, stating the files were corrupted. downloading the same files one by one, without zipping them works fine. I am posting my code cutting out those parts that deal with form data extraction and such stuff, assuming here can't be the reason.
#!/usr/bin/perl use warnings; use Archive::Zip qw(:ERROR_CODES :CONSTANTS); . . . use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); $zipName = "../downloads/".$verzeichnis."Download.zip"; $zip = Archive::Zip->new(); $index==0; foreach (@zumzippen) { ##use IO::Compress::Zip qw(:all); #use IO::Compress::Zip qw(:ZIP_CM_STORE); ##$status = zip [ @zumzippen ] => "../downloads/".$verzeichnis."Do +wnload.zip"; # , Autoclose => 1; #Method => ZIP_CM_DEFLATE , Level => + Z_NO_COMPRESSION; $member = $zip->addFile( $_ , @dateiliste[$index]); #$member->desiredCompressionMethod( COMPRESSION_STORED ); #$crc = $zip->computeCRC32( $zipName ); #$member->desiredCompressionLevel( 8 ); $index++; } # $zip->addTree("../downloads/$verzeichnis", "$verzeichnis"); #$status = $zip->writeToFileNamed("../downloads/".$verzeichnis.$zi +pName); $status = $zip->writeToFileNamed($zipName); }
As you can see, I also tried compress::zib with the same results. Any hints/help appreciated !
Thanks to Corion I can alter my question:#!/usr/bin/perl #use warnings; . . . sub download { use CGI; $html=new CGI; print $html->header(-type => 'application/octet-stream', -attachment = +> $_[1]); open($peunter, "<", $_[0].$_[1]); binmode($peunter); binmode STDOUT; while (read($pointer,$bytes,1024)) { print $bytes; } #@data = <$peunter>; close($peunter); #print "@data"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CRC Error on ZIP Files
by hazylife (Monk) on Mar 01, 2014 at 16:09 UTC | |
by SearchigPerl (Acolyte) on Mar 01, 2014 at 16:57 UTC | |
|
Re: CRC Error on ZIP Files
by AnomalousMonk (Archbishop) on Mar 01, 2014 at 17:00 UTC | |
by SearchigPerl (Acolyte) on Mar 01, 2014 at 17:34 UTC | |
by Corion (Patriarch) on Mar 01, 2014 at 18:03 UTC | |
by SearchigPerl (Acolyte) on Mar 01, 2014 at 19:22 UTC | |
by Corion (Patriarch) on Mar 02, 2014 at 06:28 UTC | |
by graff (Chancellor) on Mar 01, 2014 at 19:56 UTC | |
by aitap (Curate) on Mar 02, 2014 at 11:37 UTC | |
by ww (Archbishop) on Mar 01, 2014 at 17:56 UTC | |
by SearchigPerl (Acolyte) on Mar 01, 2014 at 18:59 UTC | |
|
Re: CRC Error on ZIP Files
by hazylife (Monk) on Mar 02, 2014 at 12:08 UTC | |
|
Re: CRC Error on ZIP Files
by hazylife (Monk) on Mar 04, 2014 at 11:09 UTC | |
by SearchigPerl (Acolyte) on Mar 05, 2014 at 18:31 UTC | |
by hazylife (Monk) on Mar 07, 2014 at 11:33 UTC | |
by SearchigPerl (Acolyte) on Mar 11, 2014 at 18:56 UTC | |
by hazylife (Monk) on Mar 11, 2014 at 21:14 UTC | |
|