我正在尝试使用 addField 方法向 Multipart HTTP POST 添加额外的字段,但是当我使用 WireShark 捕获数据包时,我看不到它的效果。可能是什么问题呢?
private void upload3(File file) {
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url + "?recname=" + fileName);
MultipartEntity entity = new MultipartEntity();
String boundary = "---------------------------This is the boundary";
httpPost.addHeader("Content-Type", "multipart/form-data; boundary="
+ boundary);
try {
File f = new File( file_path);
FileBody body = new FileBody(f);
FormBodyPart fbp = new FormBodyPart( "file", body );
fbp.addField("Content-Type", "audio/mp4");
entity.addPart(fbp);
} catch (Exception e) {
e.printStackTrace();
}
httpPost.setEntity(entity);
}