1.Retrofit接口定义:@Multipart@POST(RequestUrl.BANK_CARD_INFO)Observable>bankCardInfo(@PartMultipartBody.Partfile); 2.使用:StringtraceId=UUID.randomUUID().toString();//随机生成唯一traceIdStringpath=selectList.get(0).getPath();//Log.d(TAG,"onActivityResult:1616="+path);Filefile=newFile(path);RequestBodyfileBody=RequestBody.create(MediaType.parse("image/*"),file);//RequestBodyrequestBody=RequestBody.create(MediaType.parse("multipart/form-data"),file);RequestBodytraceBody=RequestBody.create(MediaType.parse("multipart/form-data"),file);//RequestBodyfileRQ=RequestBody.create(MediaType.parse("multipart/form-data"),file);//MultipartBody.Partpart=MultipartBody.Part.createFormData("picture",file.getName(),fileRQ);Toast.makeText(this,"1933="+traceId,Toast.LENGTH_SHORT).show();RequestBodybo=newMultipartBody.Builder().addFormDataPart("trace_id",traceId,traceBody).addFormDataPart("image",file.getName(),fileBody).build();MultipartBody.PartmyBody=//MultipartBody.Part.createFormData();MultipartBody.Part.createFormData("image",file.getName(),bo);//name为传递文件的键//todo:传递银行卡照片到智趣,返回银行卡信息RxManager.getMethod().bankCardInfo(myBody).compose(RxUtil.schedulers(this)).subscribe(newRxCallback
守候你守候我
相关分类