这是后台那边要求的接收到的数据结构,当时看到这个有点懵,后来百度了下,才知道了里面的原委。
直接贴出来代码: 首先在api中
@Multipart
@POST("xxxx/xxxx")
Observable<JSONObject> uploadPicture(@Part MultipartBody.Part file);
在pst中的请求需要对File文件进行操作
File file=new File(StrPath); //根据自己项目的需求而定。
RequestBody requestBody=RequestBody.create(MediaType.parse("image/jpg"),file);
MultipartBody.Part photoPart=MultipartBody.Part.createFormData("file",path,requestBody);
uploadPicture(photoPart);
这样子就可以了,在此作为记录以后可查看。