Actually, I\'m new in this field.facing some problem during image upload.the process automatically suspended after some time.I am attaching my code below.Please anyone helps me
You should upload your file like this
File file1 = new File(mediaPath);
int id=24;
// File file2 = new File(mediaPath);
RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), file1);
MultipartBody.Part body = MultipartBody.Part.createFormData("photo", file.getName(), requestFile);
RequestBody requestBodyid = RequestBody.create(MediaType.parse("multipart/form-data"),id);
ApiService getResponse = ApiClient.getClient().create(ApiService.class);
// Call<ServerResponse> call = getResponse.uploadFile(fileToUpload1);
Call<ServerResponse> call = getResponse.uploadFile(body,requestBodyid);
instead of
RequestBody requestBody1 = RequestBody.create(MediaType.parse("image/*"), file1);
EDIT: You forgot to create request body for the id. Add these to the code.
RequestBody requestBodyid = RequestBody.create(MediaType.parse("multipart/form-data"), id);
Where id is your id, i.e id=24.
If your problem is that progress bar is not getting hidden, you are not calling progressDialog.dismiss();
in onFailure
function.