To view the image right in the browser, I was able to solve as follows, I used the function GetInvocationMetaData
, have to specify to the browser which return. I will put an example of how I did:
declare in 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;
Look, I can’t tell you if that’s your problem, but I’ve had trouble moving images between services. It simply only accepted native types The solution was to convert the image to Base64 and traffic it as a string.
– Victor Tadashi
I was able to solve it, but I need to convert the image to Base64 anyway, I’m testing with Postman, to see if it shows the converted image to Base64. Thanks
– Jefferson Rudolf