3.Retrofit上传头像给后端

appService:

//上传头像
@Multipart
@POST
(Constants.UPLOADIMG)
Observable
uploadUserImg(@Part("managerid") int managerid, @PartMap Map, RequestBody> params);

 

接口:

public void uploadImg(int managerId,FileimgFile, final UserCenterMvpView userCenterMvpView) {

   
Map, RequestBody>params = RetrofitParameterBuilder.newBuilder()
           
.addParameter("file", imgFile)
           
.bulider();


   
retrofitHelper.toSubscribe(req.uploadUserImg(managerId,params), new Subscriber() {
       
@Override
       
public void onCompleted() {
           
Log.d("dddd", "success");
           
userCenterMvpView.onGetDataCompleted();
       
}

       
@Override
       
public void onError(Throwable e) {
           
Log.d("dddd", e.toString());
           
userCenterMvpView.onGetDataError(e);
       
}

       
@Override
       
public void onNext(KongBeanemptyMessage) {
           
Log.d("dddd", "successd");
           
userCenterMvpView.uploadImg(emptyMessage);
       
}
   
});
}

 

你可能感兴趣的:(android,android中餐)