8、RxJava+Retrofit+okhttp上传多张图片给后台

Map<String,RequestBody> params = new HashMap<>();

            for (int i = 0; i <path3.size(); i++) {

                File file1 = new File(path3.get(i));

                RequestBody requestBody1 =RequestBody.create(MediaType.parse("multipart/form-data"), file1);

                params.put("file\";filename=\"" + file1.getName(), requestBody1);

            }

 

上传服务器的presenter:

 

public voidsubmit2(Map<String, RequestBody> params) {

       retrofitHelper.toSubscribe(req.saveFile(params), newSubscriber<KongBean>() {

            @Override

            public void onCompleted() {

                Log.d("000000","searchCompleted");

                mvpView.onGetDataCompleted();

            }

 

            @Override

            public void onError(Throwable e) {

                Log.d("000000","searchError");

                mvpView.onGetDataError(e);

            }

 

            @Override

            public void onNext(KongBeanjsonObject) {

                Log.d("000000","searchNext");

               mvpView.onGetDataNext2(jsonObject);

            }

        });

}

 

appService:

 

   @Multipart

   @POST(Constants.WCJ_SAVE2)

   Observable<KongBean> saveFile(@PartMap Map<String,RequestBody> params);


阅读更多
文章标签: retrofit
个人分类: android
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭