【发布时间】:2013-04-09 10:49:52
【问题描述】:
我正在使用 google-http-client for java 来处理 Android 上的 http 连接。
到目前为止,一切都是 HunkyDori直到尝试发送 multipart/form-data 内容。
我有点卡住了,我正在考虑调整 MultipartContent 类来创建我自己的 MultipartFormContent 版本。
我需要一个MultipartEntity 的版本,它可以像这样有效地工作:
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
FileBody bin = new FileBody(new File(fileName));
StringBody comment = new StringBody("Filename: " + fileName);
MultipartEntity reqEntity = new MultipartEntity();
reqEntity.addPart("bin", bin);
reqEntity.addPart("comment", comment);
httppost.setEntity(reqEntity);
HttpResponse response = httpclient.execute(httppost);
HttpEntity resEntity = response.getEntity();
通过阅读,multipart/relative 和 multipart/form 之间的唯一区别是打印输出时添加名称?
任何人都对调整 MultipartContent 类以支持“名称”字段有任何想法。
问候。
【问题讨论】:
标签: android google-http-client