5,655
社区成员
发帖
与我相关
我的任务
分享
HttpClient httpclient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(path);
// 一个本地的文件,这里的文件必须先临时存储一次;
FileBody bin = new FileBody(new File(filePath));
// 多部分的实体
MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
mpEntity.addPart("originalMd5", new StringBody(params, "text/plain", Charset.forName("UTF-8")));
// // 增加
mpEntity.addPart("ZipMd5", bin);
// // 设置
// httpPost.setConnectionRequest((ClientConnectionRequest)request);
httpPost.setEntity(mpEntity);
System.out.println("执行: " + httpPost.getRequestLine());
HttpResponse response = httpclient.execute(httpPost);
HttpEntity resEntity = response.getEntity();