android上传视频
16lz
2022-01-24
MultipartBody.Builder mbody = new MultipartBody.Builder().setType(MultipartBody.FORM); Log.e("cxy",selectList.get(0).getPath()); File file = new File(selectList.get(0).getPath()); MultipartBody.Part body = MultipartBody.Part.createFormData("file", file.getName(), RequestBody.create(MediaType.parse("multipart/form-data"), file)); mbody.addPart(body); //构建请求体 RequestBody requestBody = mbody.build(); OkHttpClient.initPost("http://192.168.1.17:8080/files", requestBody).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { Log.e("cxy","GG:"+e.getMessage()); } @Override public void onResponse(Call call, Response response) throws IOException { Log.e("cxy",response.body().string()); } });
更多相关文章
- Android电子拍卖系统总结四
- Android从零开始-Gradle详解
- Android,HTTP请求中文乱码
- Android结合Retrofit实现统一加解密处理(Get、Post、Delete、Put)
- 【幻灯片分享】凡客移动应用之Android(安卓)+ HTML5技术运用 |
- Android(安卓)6.0权限处理问题
- app在android studio的构建过程
- Android构建模块
- android 蓝牙ble app开发(二) -- 关键概念,连接参数,连接请求