本文介绍了通过改造中发布多个图像文件需要帮助?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何一起使用改造等文本数据在相同的参数添加多个图像/文件?
单个图像上传完全采用如下的界面 @Multipart @POST(/用户/ updateProfile /) 公共无效updateProfileWithImage( @Part(USER_ID)TypedString FIRST_NAME, @Part(图像)TypedFile形象, 回调< WebResponse的>回电话);解决方案
您可以使用@MultiPart邮报 @PartMap为参数
地图<字符串,TypedFile>文件=新的HashMap<字符串,TypedFile>(); files.put(我的文件一把手,新TypedFile(图像/ JPG,新的文件(文件名))); files.put(我的文件二把手,新TypedFile(图像/ JPG,新的文件(文件名))); apiInterface.updateProfileWithImage(这里头名,文件); 专用接口ApiInterface { @Multipart @POST(/用户/ updateProfile /) 响应updateProfileWithImage( @Part(USER_ID)TypedString FIRST_NAME, @PartMap地图<字符串,TypedFile>档 ); }How to add multiple images/files on a same parameter along with other textual data using retrofit?
Single image is uploading perfectly using following interface @Multipart @POST("/users/updateProfile/") public void updateProfileWithImage( @Part("user_id") TypedString first_name, @Part ("image") TypedFile image, Callback<WebResponse> callback);解决方案
You can use the @MultiPart Post with @PartMap as parameter
Map<String, TypedFile> files = new HashMap<String, TypedFile>(); files.put("my file number one", new TypedFile("image/jpg", new File(filename))); files.put("my file number two", new TypedFile("image/jpg", new File(filename))); apiInterface.updateProfileWithImage("first name here", files); private interface ApiInterface{ @Multipart @POST("/users/updateProfile/") Response updateProfileWithImage( @Part("user_id") TypedString first_name, @PartMap Map<String,TypedFile> Files ); }
更多推荐
通过改造中发布多个图像文件需要帮助?
发布评论