通过改造中发布多个图像文件需要帮助?

编程入门 行业动态 更新时间:2024-10-07 12:23:25
本文介绍了通过改造中发布多个图像文件需要帮助?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何一起使用改造等文本数据在相同的参数添加多个图像/文件?

单个图像上传完全采用如下的界面     @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 ); }

更多推荐

通过改造中发布多个图像文件需要帮助?

本文发布于:2023-10-10 18:10:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1479344.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   图像文件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!