Retrofit+RxJava上传Map类型的表单、文件

  1. 表单
    /**
     * 工单录入
     */
    @Multipart
    @POST("your url")
    Observable<JavaBean> addOrder(@PartMap HashMap<String, String> body);
  1. 多文件上传
 for (String pathItem : imageLists) {
            if (!TextUtils.isEmpty(pathItem)) {
                File file = new File(pathItem);
                RequestBody requestFile = RequestBody.create(MediaType.parse("image/jpg"), file);
                MultipartBody.Part body = MultipartBody.Part.createFormData("pictures", file.getName(), requestFile);// pictures 是参数名
                list.add(body);
            }
        }

同时上传多个参数 和图片

    @Multipart
    @POST(WorkSheetUriConstant.uploadIamge)
    Observable<BaseResponse> upLoadImages(@QueryMap Map<String,String> params, @Part List<MultipartBody.Part> partList);

猜你喜欢

转载自blog.csdn.net/guojiayuan002/article/details/80989195