Why I do not get all the image data in an Indy HTTP connection FireMonkey?

  

I am developing a mobile application in FireMonkey and I want to take a photo with smartphone camera and store it in my Firebird database.

I’m having several problems passing the image data through the HTTP connection which I use, since not I get all the image data in the server and I think there is a maximum size for parameter in the GET request of the HTTP connection or similar something.

This is the code I use:

SAVE IMAGE DATA IN STREAM. PASS STREAM TO JSON

stream := TMemoryStream.Create;
try
image.Bitmap.SaveToStream(stream);
stream.Position := 0;
jsonPhoto := TJSONArray.Create;
try
jsonPhoto := TDBXJSONTools.StreamToJSON(stream, 0, stream.Size);
finally
//jsonPhoto.Free;
end;
finally
stream.Free;
end;

The size of jsonPhoto.toString, where the image data are, is 2368 bytes.

SEND DATA TO SERVER BY HTTP CONNECTION

try
result := IdHTTP1.Get(TIdURI.PathEncode(‘http://’+MyDirIP+’:8080/DATABASE_NAME?USERNO=’+userNum+’&BUILDINGNO=’+jsonBuildNo+’&BUILDINGNAME=’+jsonBuildName+’&OBJECTNO=’+jsonObjNo+’&OBJECTNAME=’+jsonObjName+’&PHOTO=’+jsonPhoto.ToString+’&NOTE=’+memo_Notes.Lines.Text));
except
on E: Exception do begin
ShowMessage(‘Error connection: ‘+E.Message);
end;
end;

The content of jsonPhoto.toString I get on the server has not all data who I sent, by this reason, I think that there is a parameter size by default in the HTTP connection. Moreover, I have tested that the size of image data received is 999 bytes. In the other parameters I get all the information without problem.

Moreover, when I get data in server, Should I save it in database like a json text or like a stream?

Thanks!

Comments are closed.