I developed an application made with Web Service REST
, where the data is consumed for each client request, everything works perfectly, I created Web Service REST
from DataSnap REST Application
, so a form is available to determine the port that I'm going to use, but I had to migrate that application to a Serviço
, the image return did not work with the same function that I use in the Web Service REST
application, I can return the image in png/jpeg
. I created this service from DataSnap Server
, including the JavaScript
library.
I will post the source of how do I return the image in Web Service REST
:
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;
s := CarregarImagem(sCaminho);
GetInvocationMetadata(True).ResponseContentType := 'image/png';
GetInvocationMetadata(True).ResponseCode := 200;
GetInvocationMetadata(True).ResponseContent := s;
GetInvocationMetadata(True).CloseSession := True;
I hope I have been clear. Hugs!