Image data from camera not completely in server through 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 content of jsonPhoto.toString, where the image data are, is as follows:

[137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,48,0,0,0,48,8,6,0,0,0,87,2,249,135,0,0,0,4,115,66,73,84,8,8,8,8,124,8,100,136,0,0,7,102,73,68,65,84,104,129,197,154,79,143,28,73,17,197,127,17,153,213,99,123,108,131,102,237,89,89,44,210,226,195,122,185,32,78,112,64,62,88,50,220,56,123,230,108,127,22,190,134,15,112,181,231,204,205,28,248,8,32,14,156,240,172,199,12,104,129,101,241,206,116,87,70,112,136,204,234,236,158,209,90,154,246,170,75,106,85,87,117,189,172,202,248,243,226,101,84,203,175,126,253,75,55,51,124,94,56,57,57,65,114,162,148,66,34,33,34,44,108,129,170,114,99,231,6,251,251,251,204,125,142,170,226,238,152,25,57,103,182,138,127,240,224,1,0,127,63,62,225,213,171,87,232,144,113,247,105,128,209,71,84,149,253,143,246,121,244,232,17,231,118,142,170,82,74,1,64,68,182,138,207,170,26,22,112,65,36,145,44,6,80,5,28,114,153,33,38,20,45,44,88,32,34,184,251,180,223,54,62,155,217,100,133,182,15,247,56,113,32,211,197,238,245,92,119,237,182,241,185,119,199,202,143,170,177,23,199,185,120,1,63,62,225,213,171,87,232,144,113,247,105,128,209,71,84,149,253,143,246,121,244,232,17,231,118,142,170,82,74,1,64,68,182,138,207,170,26,22,112,65,36,145,44,6,80,5,28,114,153,33,38,20,45,44,88,32,34,184,251,180,223,54,62,155,217,100,133,182,15,247,253,143,246,121,244,232,17,231,118,142,170,82,74,1,64,68,182,138,207,170,26,22,112,65,36,145,44,6,80,5,28,114,153,33,38,20,45,44,88,32,34,184,251,180,223,224,1,0,127,63,62,225,213,171,87,232,144,113,247,105,128,209,71,226,195,122,185,32,78,112,64,62,88,50,220,56,123,230,108,127,22,190,134,15,112,181,231,204,205,28,248,8,32,14,156,240,172,199,12,104,129,101,241,206,116,87,70,112,136,204,234,236,158,209,90,154,246,170,75,106,85,87,117,189,172,202,248,243,226,101,84,203,175,126,253,75,55,51,124,94,56,57,57,65,114,162,148,66,34,33,34,44]

The size of these image data 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 is as follows:

[137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,48,0,0,0,48,8,6,0,0,0,87,2,249,135,0,0,0,4,115,66,73,84,8,8,8,8,124,8,100,136,0,0,7,102,73,68,65,84,104,129,197,154,79,143,28,73,17,197,127,17,153,213,99,123,108,131,102,237,89,89,44,210,226,195,122,185,32,78,112,64,62,88,50,220,56,123,230,108,127,22,190,134,15,112,181,231,204,205,28,248,8,32,14,156,240,172,199,12,104,129,101,241,206,116,87,70,112,136,204,234,236,158,209,90,154,246,170,75,106,85,87,117,189,172,202,248,243,226,101,84,203,175,126,253,75,55,51,124,94,56,57,57,65,114,162,148,66,34,33,34,44,108,129,170,114,99,231,6,251,251,251,204,125,142,170,226,238,152,25,57,103,182,138,127,240,224,1,0,127,63,62,225,213,171,87,232,144,113,247,105,128,209,71,84,149,253,143,246,121,244,232,17,231,118,142,170,82,74,1,64,68,182,138,207,170,26,22,112,65,36,145,44,6,80,5,28,114,153,33,38,20,45,44,88,32,34,184,251,180,223,54,62,155,217,100,133,182,15,247,56,113,32,211,197,238,245,92,119,237,182,241,185,119,199,202,143,170,177,23,199,185,120,1

As you can see, I do not get 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 for your attention

Comments are closed.