c++builderdatasnapc++builder-10.1-berlin

How downloading binary files from DataSnap?


I am using RAD Studio 10.1 Berlin. I am trying to create a server method in DataSnap to serve binary files:

FileStream* TServerMethods::acceptExportReport(const String& fileName)   
{ 
    TStream* stream  = new TFileStream(outPath, fmOpenRead | fmShareDenyNone);
    stream->Position = 0;
    GetInvocationMetadata()->ResponseContentType = "application/octet-stream";
    return stream;
}

When I open it from web browser, I get json content, not binary data. Something like:

  {"result":[[45,45,45,45,45...

What I am doing wrong?


Solution

  • put ?json=false at the end of the url