ApiService
@POST(Api.uploadSickCirclePicture)//URI地址
@Multipart
Observable<ResponseBody> uploadSickCirclePicture(@Query("sickCircleId") String sickCircleId,
@Part List<MultipartBody.Part> files);
代码
List<MultipartBody.Part> files=new ArrayList<>();
//本地图片路径localMedia.get(i).getPath();
String path = localMedia.get(i).getPath();
File file = new File(path);
//上传
RequestBody requestBody = MultipartBody.create(MediaType.parse("multipart/form-data"), file);
MultipartBody.Part image = MultipartBody.Part.createFormData("picture", file.getName(), requestBody);
files.add(image);
//请求接口
presenter.requestUploadSickCirclePicture(id, files);
网友评论