-3

I have a problem migrating a process from XE8 to Berlin 10.1.

On XE8, it works fine.

On Berlin, I get a "Loading Bitmap Failed" error.

I have a DataSnap REST server with this method:

function TSM.Downloafile(): TStream;
var
  s: TFileStream;
begin
  s := TFileStream.Create('C:\image1.jpg', fmOpenReadWrite);
  Result := s;
end;

On XE8, I get the stream fine, I can see the image using a URL in a browser, like:

http://localhost:105/datasnap/rest/TSM/Downloafile

On Berlin, when I try to show the image, I get this string instead:

[122,216,255,244,0,15,......]

And then loading of the Bitmap fails.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Dison
  • 103
  • 1
  • 1
  • 12
  • As just a side note, there's no reason to use `fmOpenReadWrite` if you don't intend to write. In some environments, this could even fail if you don't have write privileges to the given folder. – Jerry Dodge Jan 20 '17 at 21:10
  • Also, I doubt this is related to Firemonkey, considering you're talking about a REST Server accessed from a Browser. I suggest change your question to be focused on the fact that your REST server is returning an unexpected format. – Jerry Dodge Jan 20 '17 at 21:11
  • As far as your actual problem, we cannot see enough relevant code. Where do you handle the request/response? What do you pass for `ContentType`? – Jerry Dodge Jan 20 '17 at 21:13
  • Further aside, no point of the local variable s, assign directly to Result – David Heffernan Jan 21 '17 at 07:56
  • I have not set ContentType as i said on XE8 work fine i can see the image, the problem is on Berlin, the stream return a string like [122,216,255,244,0,15,......] and fail – Dison Jan 23 '17 at 14:25

2 Answers2

0

i have resolved this case using ?json=false in the URL, thanks

Dison
  • 103
  • 1
  • 1
  • 12
-1

when you say DataSnap REST server i guess then the TSM.Downloafile(): TStream; is not call from the main thread. bitmap are not multithread and must be use only from the main thread

zeus
  • 12,173
  • 9
  • 63
  • 184
  • this code work fine on XE8, the problem is on Berlin that return a string like [122,216,255,244,0,15,......] and fail – Dison Jan 23 '17 at 14:23