hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael S├╝dkamp <michael.suedk...@docware.de>
Subject File upload with PUT method
Date Fri, 21 Jan 2005 11:00:41 GMT
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: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Mime
View raw message