Retrofit上传图文
来源:互联网 发布:python股票分析系统 编辑:程序博客网 时间:2024/06/13 12:35
接口
private interface DemoImp { @Multipart @POST("your url") Call<String> addParams( @Part("content")String content, @Part("location")String location, @PartMap() Map<String, RequestBody> maps); }
添加文件
public void demo(String content,String location,List<File> files){SendDiscoverImp sendDiscoverImp = RetrofitManager.getRetrofit().create(SendDiscoverImp.class); Map<String, RequestBody> maps = new HashMap<>(); int size = files.size(); for (int i = 0; i < size; i++) { RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), files.get(i)); maps.put("photos\"; filename=\""+ GeneralUtils.fileReName(files.get(i)), requestFile); }}
photos是和服务器约定的字段,注意是分号不是冒号,格式不可以有错,filename是上传到服务器上的文件名
0 0
- Retrofit上传图文
- retrofit 图文上传
- retrofit图文上传
- Android Retrofit 实现图文上传(二)
- Retrofit实现图文上传至服务器
- Android Retrofit 实现图文上传-文字参数类型
- Android Retrofit 实现图文上传-文字参数类型
- 【Android实战】----基于Retrofit实现多图片/文件、图文上传
- 【Android实战】----基于Retrofit实现多图片/文件、图文上传
- 【Android实战】----基于Retrofit实现多图片/文件、图文上传
- Android Retrofit 实现(图文上传)文字(参数)和多张图片一起上传
- 图文上传
- Retrofit 上传图片(单张)
- Retrofit 2.0文件上传
- 使用Retrofit上传文件
- retrofit上传图片
- Retrofit上传图片
- Retrofit上传头像
- 大三软件工程小项目-小技术集合-服务端连接MySQL及对表插入、删除、查询
- react-native热更新闪屏问题
- git使用详解
- 11款PHP集成开发环境
- 分而治之——Different Ways to Add Parentheses
- Retrofit上传图文
- Rancher如何按计算资源调度
- HDU1159
- SQL主键简单表述
- OpenCV关于视频处理的学习(VideoCapture类)-在检测中一些必要的图像操作
- preprocess函数
- oj1045: 输入一个数插入有序数组中
- mysql的事务性,锁和隔离性
- 网络流24题5. 圆桌问题