Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Re: Downloading images to client PCs

by MrCromeDome (Deacon)
on Sep 12, 2002 at 18:45 UTC ( [id://197310]=note: print w/replies, xml ) Need Help??


in reply to Re: Downloading images to client PCs
in thread Downloading images to client PCs

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

Replies are listed 'Best First'.
Re^3: Downloading images to client PCs
by dws (Chancellor) on Sep 12, 2002 at 19:56 UTC
    Same problem though: when the zip file gets to the client, it's not usable.

    Archive::Zip says this:

    Under Windows, things lock up/get damaged

    Q: I'm using Windows. When I try to use Archive::Zip, my machine locks up/makes funny sounds/displays a BSOD/corrupts data. How can I fix this?

    A: First, try the newest version of Compress::Zlib. I know of Windows-related problems prior to v1.14 of that library.

    If that doesn't get rid of the problem, fix your computer or get rid of Windows.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-25 22:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found