I'm trying to make an app which sends a image to a server, it transforms the image and it return to the app. But when the app receive the image, only receive a part of it. I did a web with flask and I saw that it send well the picture, and I used Okhttp to download a picture from Internet I don't have any problem.
To send the picture from server I've used:
return flask.send_from_directory('path') and return flask.send_file(...)
To send and receive the picture in the client I've used:
void postRequest(String postUrl, RequestBody postBody) {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(postUrl)
.post(postBody)
.build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
// Cancel the post on failure.
call.cancel();
Log.d("FAIL", e.getMessage());
// In order to access the TextView inside the UI thread, the code is executed inside runOnUiThread()
runOnUiThread(new Runnable() {
@Override
public void run() {
TextView responseText = findViewById(R.id.responseText);
responseText.setText(R.string.ip_failure);
}
});
}
@Override
public void onResponse(Call call, final Response response) throws IOException {
// In order to access the TextView inside the UI thread, the code is executed inside runOnUiThread()
runOnUiThread(new Runnable() {
@Override
public void run() {
TextView responseText = findViewById(R.id.responseText);
responseText.setText("");
try {
Bitmap imagenGAN;
imagenGAN = BitmapFactory.decodeStream(response.body().byteStream());
ImageView imagen = findViewById(R.id.imageView);
imagen.setImageBitmap(imagenGAN);
SaveImage(imagenGAN);
}catch(Exception e){
}
}
});
}
});
}
Example of the received image:

I don't know why I don't receive the full image. Can someone help me?