Map<String, RequestBody> params = new HashMap<>();
RequestBody a= RequestBody.create(MediaType.parse("multipart/form-data"), "");
params.put("123", a);
//上传多张图片
for (int i = 0; i < datas.size(); i++) {
File file = new File((String) images.get(i).get("path"));
RequestBody imgFile = RequestBody.create(MediaType.parse("image/jpeg"), file);
MultipartBody.Part requestImgPart = MultipartBody.Part.createFormData("Image"+i, file.getName(), imgFile);
params.add(requestImgPart);
}
//上传Json
String json = new Gson().toJson(bean);
RequestBody body = RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), json);
@POST("URL/Create")
@Multipart
Call<BaseCallBack<List<ListCallBack<Bean>>>> postCreateBean(@Part("JsonData") RequestBody requestbody,
@Part List<MultipartBody.Part> request_img_part);