On Fri, 2005-12-09 at 14:59 +0100, Bastian Tweddell wrote:
> I dont know how to upload a file with the PostMethod (btw uploading files
> with the PutMethod worked great, but i need to upload large files)
> 
> I have read the whole day and didnt find anything that could help me. The 
> code i have so far should upload the local file 'local=/home/my/file.a' to
> the url 'http://loclahost:8080/username/file.b' (because different names
> should be possible)
> 
> 
> PostMethod method2 = null;
> try {
>       System.out.println();
>       method2 = new PostMethod(url + "/" + remote);
>       Part[] parts = {
>               new FilePart(local.getName(), local)
>       };
>       method2.setRequestEntity(
>               new MultipartRequestEntity(parts, method2.getParams())
>       );
> } catch (FileNotFoundException e) {
>       log.warning("File doesnt exist: " + local);
>       e.printStackTrace();
>       return false;
> }
> try {
>       // Execute the
> method.
>       
> httpclient.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
> int statusCode = httpclient.executeMethod(method2);
> if (statusCode != HttpStatus.SC_OK) {
>       log.warning("PostMethod failed: " + method2.getStatusLine() + "
> Statuscode="+statusCode);
>                       } else {
> .
> .
> .

> But this doesnt work. And i really Dont know if this is a client or server
> side problem. 

Bastian,

You can monitor what gets sent and received across the wire by
activating the wire logging. For details see the HttpClient logging
guide

http://jakarta.apache.org/commons/httpclient/logging.html

Oleg



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to