To view the right image in the browser, I was able to solve it as follows, I used the GetInvocationMetaData
function, I have to specify for the browser what the return is. I'll put an example of how I did it:
declare non usues Data.DBXPlatform
function CarregarImagem(const sCaminho: String): AnsiString;
var
oFileStream : TFileStream;
begin
oFileStream:= TFileStream.Create(sCaminho, fmOpenRead or fmShareDenyWrite);
try
if oFileStream.Size > 0 then
begin
SetLength(Result, oFileStream.Size);
oFileStream.Read(Pointer(Result)^, oFileStream.Size);
end;
finally
FreeAndNil(oFileStream);
end;
end;
sImagem := CarregarImagem(sDirImagem);
if (bExtPNG) then
GetInvocationMetadata().ResponseContentType := 'image/png'
else
begin
GetInvocationMetadata().ResponseContentType := 'image/jpeg';
GetInvocationMetadata().ResponseCode := 200;
GetInvocationMetadata().ResponseContent := sImagem;
GetInvocationMetadata().CloseSession := True;
end;