而不是使用@Part try@字段
@Multipart
@POST("/api/mbrphotos/prfImgIU/{memberId}/{actionType}")
Call<JsonObject> postImage(@Part("memberId") RequestBody memberId,
@Part("actionType") RequestBody actionType,
@Part MultipartBody.Part[] multipartTypedOutput);
在你的
Activity
使用此方法发送邮件
public void sendPost(String memberId, String actionType) {
final ProgressDialog dialog = new ProgressDialog(this);
dialog.setMessage("Please wait...");
dialog.setCancelable(false);
dialog.show();
MultipartBody.Part[] multipartTypedOutput = new MultipartBody.Part[imageModelArrayList.size()];
for (int index = 0; index < imageModelArrayList.size(); index++) {
Log.d("Upload request", "requestUploadSurvey: survey image " + index + " " + imageModelArrayList.get(index).path);
File file2 = new File(imageModelArrayList.get(index).path);
RequestBody surveyBody = RequestBody.create(MediaType.parse("image/*"), file2);
multipartTypedOutput[index] = MultipartBody.Part.createFormData("imageFiles[]", file2.getPath(), surveyBody);
}
RequestBody memberId1 = RequestBody.create(MediaType.parse("text/plain"), memberId);
RequestBody actionType1 = RequestBody.create(MediaType.parse("text/plain"), actionType);
apiService.postImage(memberId1, actionType1, multipartTypedOutput).enqueue(new Callback<JsonObject>() {
@Override
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
Log.d("fb_regist_response", "--->" + "" + response);
dialog.dismiss();
}
@Override
public void onFailure(Call<JsonObject> call, Throwable t) {
Log.d("onFail_fb_regist_res", t.getMessage());
dialog.dismiss();
}
});
}