I like this suggestion. . . pre-zipping the TIFFs is not terribly feasible, but it was pretty easy to whip something up to create them on the fly. Same problem though: when the zip file gets to the client, it's not usable. I was able to open the downloaded zip and look at the contents, but when I tried to view the contents, WinZip reports "Extracting building.jpg; Error: invalid compressed data to inflate." I opened the zip that was created on the fly (the one on the server) to make sure it was valid, and the file seemed ok.
The code I used looks like this:
my $file = 'd:\imaging\building.jpg';
my $zip_name = get_session() . ".zip";
my $zip = Archive::Zip->new();
$zip->addFile($file) or die "Can't add to zip!\n";
$zip->writeToFileNamed($zip_name);
my $filesize = -s $zip_name;
my $buffer;
# Read the zip file
open READ, "< $zip_name" or die "Cannot open $zip_name for reading: $!
+";
binmode READ;
{
local $/;
$buffer = <READ>;
}
close(READ);
binmode STDOUT;
print "Content-Disposition: inline; filename=document.zip\n";
print "Content-Length: $filesize\n";
print "Content-Type: application/zip\n\n";
print $buffer;
I'm serving this up with Apache 2.0.40 on WinXP.
MrCromeDome