Board index » delphi » Sending a generated JPEG as a response

Sending a generated JPEG as a response


2007-05-03 07:09:25 PM
delphi276
Hi
I have a ISAPI DLL that interfaces with a service that generates a JPEG image.
I can, in a regular Win32 Application, retreive the image, and this seems
to be happening in the ISAPI program. Once I get the image this is the code
that I am using the following method to send the data:
procedure TwmMain.SendResponse(Response: TWebResponse; Image: TStream; FileName,
ContentType: AnsiString);
begin
Response.ContentType := ContentType;
Response.SetCustomHeader('Content-disposition', 'attachment;filename=Map.jpg');
Response.SetCustomHeader('Accept-Ranges', 'bytes');
Response.SetCustomHeader('Content-Length', IntToStr(Image.Size));
Image.Seek(0, soFromBeginning);
Response.ContentStream := Image;
Response.SendResponse;
end;
In Opera I get prompted to save the file which then when I save the file
the file is not being streamed. In IE 7 the file is streamed and is OK, again
I am prompted if I want to save the image or not.
The idea is that I pass the URL to generate the image in the following manner:
<img src="http://localhost/WebTrack.dll/Tracking?Docket=1890&Height=800&Width=600"
/>.
I am using Delphi 2006 on Windows XP (Fully updated)
TIA
Graham Harris
 
 

Re:Sending a generated JPEG as a response

Not sure what you queston is since you didnt' ask one???
Is it .. "Why is Opera not getting the file ???" ... or ..
Why does IE work and Opera doesn't ?? .. or is it a different question. Your
post is just a statement.
 

Re:Sending a generated JPEG as a response

OK fixed it
Do not need:
Response.SetCustomHeader('Content-disposition', 'attachment;filename=Map.jpg');
Graham Harris
 

Re:Sending a generated JPEG as a response

Hello Del,
The question was why was the image not being sent to the browser.
Graham Harris
Quote
Not sure what you queston is since you didnt' ask one???

Is it .. "Why is Opera not getting the file ???" ... or ..
Why does IE work and Opera doesn't ?? .. or is it a different
question. Your
post is just a statement.