I then add the following code to display an image in a browser in my unit ServermethodUnit1 and my classe TserverMethods1
TServerMethods1 = class(TDataModule)
private
{ Déclarations privées }
public
{ Déclarations publiques }
function EchoString(Value: string): string;
function ReverseString(Value: string): string;
function getFile: TFileStream;
end;
{$METHODINFO OFF}
function TServerMethods1.getFile: TFileStream;
begin
GetInvocationMetadata.ResponseContentType := 'image/png';
Result := TFileStream.Create('images\image.png', fmOpenRead or fmShareDenyNone);
end;
I start the datasnap server and i call in a browser this URl : http://localhost:61332/datasnap/rest/TServerMethods1/getFile/
The returned image is not correct :
Executed: TServerMethods1.getFile
Result: {"result":[137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,1,204,0,0,2,8,8,6,0,0,0,227,74,222,185,0,0,0,1,115,82,71,66,0,174,206
I compile the same project with Delphi 10 Seattle and Delphi XE4 and the browser displays the image correctly.
in Seattle
Executed: TServerMethods1.getFile
Result: "�PNG\r\n\u001a\n\u0000\u0000\u0000\rIHDR\u0000\u0000\u0001�\u0000\u0000\u0002\b\b\u0006\u0000\u0000\u0000�J\u0000\u0000\u0000\u0001sRGB\u0000��\u001c�\u0000\u0000\u0000\u0004gAMA\u0000\u0000��\u000b�a\u0005\u0000\u0000\u0000\tpHYs\u0000\u0000\u000b\u0013\u0000\u0000\u000b\u0013\u0001\u0000��\u0018\u0000\u0000��IDATx^��\u0005�
What is wrong in delphi 10.1 ? is this a bug ? Is there a solution?
best regards
Romuald Kler