0

I am trying to upload a file using Retrofit 2 but it is not working.

The files I am attempting to upload is an image or doc/docx type. I validate that the file exists prior to upload. I have also validated that the server information is correct.

 MultipartBody.Builder b = new MultipartBody.Builder()
       .setType(MultipartBody.FORM)
       .addFormDataPart("title", builder.getTitle()) 
       .addFormDataPart("status", String.valueOf(builder.getStatus()));

b.addFormDataPart("file_f", file1.getName(), 
       RequestBody.create(MediaType.parse("multipart/form-data"), file1));
b.addFormDataPart("file_s", file2.getName(), 
       RequestBody.create(MediaType.parse("multipart/form-data"), file2));
return b.build();
Alex Beggs
  • 1,187
  • 2
  • 11
  • 17
asf
  • 355
  • 1
  • 3
  • 17

0 Answers0