When I send a [] byte converted to String to the server on the server it comes empty or bursts. I do not understand why.
Bitmap photo = (Bitmap)data.getExtras().get("data");
photo = Bitmap.createScaledBitmap(photo, 800, 1422, false);
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
photo.compress(Bitmap.CompressFormat.PNG, 100, bytes);
byte[] imageArray = bytes.toByteArray();
String imageAsString = Base64.encodeToString(imageArray, Base64.DEFAULT);
Then to send to the server I do:
private String InsertImage(String url)
{
HttpClient client = buildHttpClient();
HttpPost request = new HttpPost(url);
HttpResponse response = null;
String responseString = "";
try
{
System.out.println("VOU PARA O SERVIDOR");
JSONObject jsonObject = this.setHeadersAndbuildJSONObject(request);
System.out.println("vou levar 1 - " + sessionID);
System.out.println("vou levar 2 - " + data[0]);
System.out.println("vou levar 3 - " + data[1]);
jsonObject.put("SessionGUID", sessionID);
jsonObject.put("Address", data[0]);
jsonObject.put("imageAsBytes", data[1]);
responseString = this.executeRequest(jsonObject, request, response, client);
System.out.println("VIM DO SERVIDOR " + responseString.toString());
}
catch (Exception e)
{
System.out.println("ERRO " + e.getMessage());
}
return responseString;
}
In system.out you see the variables are all well filled.