What is the equivalent in java for the following curl command:
curl -X POST -F "file=@$File_PATH"
The request I want to execute using Java is :
curl -X POST -F 'file=@file_path' http://localhost/files/
I was trying :
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(_URL);
File file = new File(PATH);
MultipartEntity mpEntity = new MultipartEntity();
ContentBody cbFile = new FileBody(file, "bin");
mpEntity.addPart("userfile", cbFile);
httpPost.setEntity(mpEntity);
HttpResponse response = httpClient.execute(httpPost);
InputStream instream = response.getEntity().getContent();