Hi, Michael,

I got this working with Apache 2.0 once.  It was tricky.  I had enable WebDAV.  
Maybe this information will help you.

I find it much easier to just implement a very basic "doPut()" method in a 
Servlet under Tomcat.

yours,

Julius


-----Original Message-----
From:   Michael Südkamp [mailto:[EMAIL PROTECTED]
Sent:   Fri 1/21/2005 3:00 AM
To:     [email protected]
Cc:     
Subject:        File upload with PUT method
Hi,

I have started using httpclient 3.0-beta1.

I would like to do a file upload using HTTP PUT. (this is an intranet
application so security should be OK).
This is my sample code:

    HttpClient client = new HttpClient();
    PutMethod put = new PutMethod("http://linux3/upload";);
    RequestEntity entity = new InputStreamRequestEntity(new
FileInputStream("d:\\temp\\foo.txt"));
    put.setRequestEntity(entity);

    client.getHttpConnectionManager().
        getParams().setConnectionTimeout(5000);
    int status = client.executeMethod(put);
    if (status == HttpStatus.SC_OK) {
        System.out.println("Upload complete, response=" +
put.getResponseBodyAsString());
    } else {
      System.err.println("Upload failed, response=" +
HttpStatus.getStatusText(status));
    }

My tests with IIS 5 and Apache 1.3 are:

IIS returns "Method not allowed". I think I habe to enable PUT somewhere.
But where?

With Apache my console log is:
21.01.2005 11:09:40 org.apache.commons.httpclient.HttpMethodDirector
isRedirectNeeded
INFO: Redirect requested but followRedirects is disabled
Upload failed, response=Moved Permanently
I am not really sure if this is a server or client issue.

If anyone is able to help me with IIS and/or Apache I would be glad.

Thanks

Michael


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





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

Reply via email to