Blob image to ASP Reponse

krome

Member
I have a minimal oracle dataset, it returns one row with one field. The field is a BLOB that contains a JPG image.

Assuming the dataset component is named OracleDataset1, and the field is named Field1 and it is instantiated in the designer as OracleDataset1Field1, how would I go about writing the data directly to a Response object from ASP?

I can use this to verify the field has valid jpg content: OracleDataset1Field1.SaveToFile('c:\test.jpg');

This is done inside a MTS COM component within Delphi, and I also pass in a reference to the ASP Response object marshalled as an OleVariant.

My component method looks something like this:

procedure TMyMTSComponent.GetLogoFromDB(const KeyValue: Integer; var ASPResponse: OleVariant); safecall;

I can use ASPResponse.Write('some html'), so I know that part of things is fine.

I have tried using this code, which I would expect to function but it doesnt:

ASPResponse.ContentType := 'image/jpg';
ASPResponse.BinaryWrite(OracleDataset1Field1.AsVariant);

Has anyone done this and could provide sample code of how you achieved it?

Keith
 
Back
Top