Upload picture to server using retrofit 2
问题 First of all lets look to the code: public interface ApiInterface { @Multipart @POST("my/files/photo/") Call<FileUploadResponse> uploadPhoto(@Header("authorization") String auth, @Part MultipartBody.Part file, @Part("file-type") RequestBody fileType); } I'm calling this interface like this: RequestBody body = RequestBody.create(MediaType .parse(getContentResolver().getType(fileUri)), file); MultipartBody.Part avatarBody = MultipartBody.Part .createFormData(data, file.getName(), body);