打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Datasnap rest server : return png

Datasnap rest server : problem with delphi 10.1

 

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

 

!!!!!! at the end of the URL add ?json=false


datasnap rest 会自动 将返回对象打包为json

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Delphi DataSnap 初步入门使用总结
DELPHI DATASNAP 2010 入门操作(2)不写一行代码,绿色三层我也行
DataSnap基础
Delphi Xe DataSnap Rest + Flex 开发 基本探索2(取得Json 数组)
Delphi2010中DataSnap高级技术(1)—为DataSnap系统服务程序添加描...
WebService With BizSnap 二
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服