首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏小工匠聊架构

    Android-上传图片(二)_HttpClient

    客户端核心代码如下: HttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(url); MultipartEntity multipartEntity = new MultipartEntity(); FileBody fileBody = new FileBody(file); // file 是服务端读取文件的 key "file" name="file" /> 对应的 multipartEntity.addPart("file", fileBody); httpPost.setEntity( multipartEntity); try { HttpResponse response = httpClient.execute(httpPost); if(response.getStatusLine

    53230发布于 2021-08-16
  • 来自专栏全栈程序员必看

    HttpClient4.x 文件上传

    HttpPost httpPost = new HttpPost("http://localhost/file/upload"); try { final MultipartEntityBuilder multipartEntity = MultipartEntityBuilder.create(); multipartEntity.setCharset(Charset.forName("utf-8")); multipartEntity.setMode (HttpMultipartMode.BROWSER_COMPATIBLE); //for (String[] nameValue : datas) {//普通data字段 // multipartEntity.addPart (nameValue[0], new StringBody(nameValue[1], ContentType.APPLICATION_JSON)); //} multipartEntity.addBinaryBody ("file", file);//文件字段 httpPost.setEntity(multipartEntity.build()); //httpPost.setHeader("token"

    62430编辑于 2022-09-15
  • 来自专栏向治洪

    文件图片上传

    org.apache.http.client.HttpClient;   import org.apache.http.client.methods.HttpPost;   import org.apache.http.entity.mime.MultipartEntity             HttpPost post = new HttpPost(   "http://service.ireadhome.com/api/Upload/Image");               MultipartEntity  entity = new MultipartEntity();   // 上传 文本, 转换编码为utf-8 其中"text" 为字段名, // 后边new StringBody(text,

    5.5K50发布于 2018-01-29
  • 来自专栏我的博客

    安卓上传文件(绝对可以用)

    说明:使用是httpclient+MultipartEntity,因此需要导入包:httpmime-4.1.1(这个包非常重要!务必导入!) index.php"; HttpPost httppost = new HttpPost(urlServer); File file = new File(pathToOurFile); MultipartEntity mpEntity = new MultipartEntity(); // 文件传输(这个需要用到httpmime-4.1.1.jar) ContentBody cbFile = new FileBody

    2K61发布于 2018-05-08
  • 来自专栏Android开发指南

    5.post上传和压缩、插件模拟请求

    实际开发用的很多 post.setEntity(new StringEntity(jsonString)); file形式:需要jar包httpmime:很多框架上传图片就是用他 MultipartEntity entity = new MultipartEntity(); entity.addPart("actimg", new FileBody(file)); post.setEntity 传递二进制类型的参数 MultipartEntity entity = new MultipartEntity(); entity.addPart("actimg", new FileBody

    2.5K90发布于 2018-05-14
  • 来自专栏Android开发指南

    post上传和压缩、插件模拟请求

    传递二进制类型的参数 MultipartEntity entity = new MultipartEntity(); entity.addPart("actimg", new FileBody

    88930编辑于 2022-01-12
  • 来自专栏全栈程序员必看

    使用HttpClient4,post提交multipart/form-data数据

    httpResponse.getEntity(); String content = EntityUtils.toString(httpEntity); System.out.println(content); 其中,之前版本的MultipartEntity

    1.8K10编辑于 2022-09-15
  • 来自专栏老欧说安卓

    Android开发笔记(六十三)HTTP访问的通信方式

    封装了一些常用的处理工具如get请求工具HttpGet、post请求工具HttpPost、http响应工具HttpResponse、url编码表单工具UrlEncodedFormEntity、分段传输工具MultipartEntity

    1.5K50发布于 2019-01-18
  • 来自专栏复盘总结文章集合

    spring boot + mybatis + layui + shiro搭建后台权限管理系统

    -- 提供FileBody、StringBody和MultipartEntity 使用httpClient上传文件需要的类 --> <dependency> <groupId>org.apache.httpcomponents

    4.9K20发布于 2019-10-15
领券