Ovid has asked for the wisdom of the Perl Monks concerning the following question:
All files are getting truncated to a file size that is a multiple of 4K. Not *approximately* 4K, I mean exact multiples of 4K! 4,096 bytes, 20,480 bytes, 110,592 bytes, etc. This is the $Archive::Zip::ChunkSize, but I have no idea why this would be causing an issue (if that is the problem).
Production: Perl 5.00503, NT4, IIS4.
Development: Perl 5.6, Win2K, IIS5.
Both: Same versions of CGI and Archive::Zip.
I have verified that I can open the uploaded zip file on the production server and extract the files manually. Code in question is below:
Note: I did not set up the development environment!
Anyone experienced a similar problem? I'm reading through Archive::Zip right now trying to determine what causes Archive::Zip::extractMember to stop extracting, but our clients were supposed to be using this program a couple of hours ago!sub unzip_and_save { # return a reference to scalar containing index.html # and a reference to array containing .pdf names my ( $zipFileName ) = @_; use Archive::Zip; my $zip = Archive::Zip->new; my $status = $zip->read( $zipFileName ); if ($status) { error( $cgi, $cgi->p("There is an error in your zip file. Ple +ase ensure that the file you are uploading is a valid archive and try + again.") ); } my ($member,$extractedFile, @pdfs, $index); foreach $member ($zip->memberNames()) { push @pdfs, $member if $member =~ /\.pdf$/i; # Add error checking to check for more than one index $index = $member if $member =~ /index\.html?$/; $extractedFile = UPLDTMPDIR . '\\' . $member; # only allow them to extract files with pdf or html extensions if ( $member =~ /\.(pdf|html?)$/i ) { my $status = $zip->extractMember($member,$extractedFile); if ( $status ) { error( $cgi, $cgi->p( "Error code: $status" ) ) if $st +atus; } } } if ( ! defined $index ) { error( $cgi, $cgi->p("No index.html file found in zip archive. +")); } elsif ( ! @pdfs ) { error( $cgi, $cgi->p("No pdfs found in zip archive")); } return ( $index, \@pdfs ); }
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Archive::Zip truncating data
by Dr. Mu (Hermit) on Apr 26, 2001 at 11:28 UTC | |
|
Re: Archive::Zip truncating data
by Albannach (Monsignor) on Apr 26, 2001 at 18:36 UTC | |
by Ovid (Cardinal) on Apr 26, 2001 at 21:11 UTC |