Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

sending ZIP file via HTTP POST

843789Jun 23 2009 — edited Jun 24 2009
Hi, 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 22 2009
Added on Jun 23 2009
4 comments
3,664 views