0

I am using multipart to upload a file to retrofit but enqueue is not calling

private void uploadToServer(String filePath) { Retrofit retrofit = NetworkClient.getRetrofitClient(this);

    UploadAPIs uploadAPIs = retrofit.create(UploadAPIs.class);

    //Create a file object using file path
    File file = new File(filePath);

    // Create a request body with file and image media type
    RequestBody fileReqBody = RequestBody.create(MediaType.parse("image/*"), file);

    // Create MultipartBody.Part using file request-body,file name and part name
    MultipartBody.Part part = MultipartBody.Part.createFormData("upload", file.getName(), fileReqBody);

    //Create request body with text description and text media type
    RequestBody description = RequestBody.create(MediaType.parse("text/plain"), "image-type");

    //
    Call call = uploadAPIs.uploadImage("1", "bilal", part,"03232", "abnslfjns", true);

    call.enqueue(new Callback() {

        @Override
        public void onResponse(Call call, retrofit2.Response response) {
            Log.d("MainActivity", "onResponse: " + response);

        }

        @Override
        public void onFailure(Call call, Throwable t) {
            Log.d("MainActivity", "onResponse: " + t);

        }
    });

}
Bilal
  • 13
  • 1
  • 7

0 Answers0