Reputation: 103
How convert curl call into java HttpPost:
curl --form "[email protected];type=application/pdf"
Any help appreciated.
Upvotes: 2
Views: 659
Reputation: 103
I solved my problem below the solution I used:
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);
Upvotes: 2