MrCromeDome has asked for the wisdom of the Perl Monks concerning the following question:
I post this at the risk of sounding repetitive, but I am truly baffled at this problem. I posted the original problem in this node, and have come a little ways since then, but not much. I admit I am somewhat out of my league here - I'm not terribly familiar with how HTTP headers work, which could explain most of the problem I'm having.
To recap, I have a web site which allows clients to purchase copies of selected document images online. Once the transaction has been completed, I need to send the purchased document to the client browser. Images are in multipage TIFF format with group 4 compression. I have the image being delivered to the client browser, but what the client sees when they get the image is not at all correct.
I'm left to believe that either there is something wrong with my content header, or something is happening to the image during delivery to the browser. To be honest though, I think it's something I'm doing ;) Here's what I got thus far:
I'm confident that the image reading portion of that is ok. When the debugging info gets sent to the browser, what Perl reports the size on disk to be (and the size of $buffer) match what the file size on disk actually is. Once I was sure that I was reading it ok, I worked on delivering the image. I have tried the following things listed below. Check the comment above each for the result.my $file = get_image_info($document); my $filesize = -s $file; my $buffer; # Read the image file open READ, "< $file" or die "Cannot open $file for reading: $!"; binmode READ; { local $/; $buffer = <READ>; } close(READ); # For Debugging Purposes print $request->header(), " ", length($buffer), " " , -s $file ;
Is there something obvious (or not so obvious) that I'm missing here? I spent the better part of yesterday combing through the Monastery looking for additional insight, but I can't find something different than what I've tried (or else I'm misapplying something that I've found there).# This didn't work. Displays "Save As" dialog twice, no image sent. print "Content-type: image/tiff\n"; print "Content-disposition: attachment; filename=image.tif\n\n"; print $buffer; # This kinda works. Displays "Save As" dialog twice, but image is # corruppted (see description in post). print "Content-Type: image/tiff; filename=image.tif\n"; print "Content-Disposition: attachment; filename=image.tif\n"; print "Content-Length: $filesize\n\n"; print $buffer; # Same result as above. print $request->header(-type => "image/tiff", -attachment=>'image.tif'), $buffer; # This almost works. Only displays "Save As" dialog once, image is # messed up though (see description in post). print "Content-Disposition: inline; filename=image.tif\n"; print "Content-Length: $filesize\n"; print "Content-Type: image/tiff\n\n"; print $buffer; # Same result as above, just done a bit differently. Changing the con +tent # type did nothing for me. print $request->header(-Content_Disposition => "inline; filename=image +.tif", -Content_Length => $filesize, -Content_Type => "application/octet-stream", ), $buffer;
Any help, comments, or insight are very much appreciated. Thank you!
MrCromeDome
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Downloading images to client PCs
by fglock (Vicar) on Sep 12, 2002 at 15:10 UTC | |
by MrCromeDome (Deacon) on Sep 12, 2002 at 15:39 UTC | |
|
Re: Downloading images to client PCs
by guha (Priest) on Sep 12, 2002 at 15:15 UTC | |
|
Re: Downloading images to client PCs
by valdez (Monsignor) on Sep 12, 2002 at 15:55 UTC | |
by tlhf (Scribe) on Sep 13, 2002 at 01:12 UTC | |
|
Re: Downloading images to client PCs
by dws (Chancellor) on Sep 12, 2002 at 17:46 UTC | |
by QwertyD (Pilgrim) on Sep 12, 2002 at 22:51 UTC | |
by MrCromeDome (Deacon) on Sep 12, 2002 at 18:45 UTC | |
by dws (Chancellor) on Sep 12, 2002 at 19:56 UTC |