sending ZIP file via HTTP POST
843789Jun 23 2009 — edited Jun 24 2009Hi, i would like to send a zip file at over HTTP POST using the Apache Commons HTTPClient
and at the receiver end i would like to read the zip file sent via HTTP POST and save it on the hard disk to verify that exactly the same contents were sent.
So far i have done the following for sending:
HttpClient client = new HttpClient () ;
MultipartPostMethod postMethod = new MultipartPostMethod ("http://localhost:8080/work/Receiver") ;
File file = new File ("myfile.zip") ;
postMethod.addParameter(file.getName(), file);
int statusCode = client.executeMethod (postMethod) ;
System.out.println("statusLine>>> " + postMethod.getStatusLine());
postMethod.releaseConnection();
This is sent to Receiver (localhost) which i want to read and save the zip file to a folder so that i can check that the sent zip file is the same as the received one. I would like to use the Commons libraries for this but there is not much info available.
Does anybody know how i can accomplish this?
Thanks in advance