如何将curl调用转换为java HttpPost:
curl --form "archive=@test.pdf;type=application/pdf"
任何帮助表示感谢。
答案 0 :(得分:2)
我解决了我的问题 在我使用的解决方案之下:
HttpPost httpPost = new HttpPost(resourceURL);
MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
File file = new File(doc.getPath());
entity.addPart("title", new StringBody(doc.getTitre()));
entity.addPart("file", new StringBody(doc.getTag()));
entity.addPart("archive", new FileBody((file), "type=application/pdf"));
httpPost.setEntity(entity);