Hello,

PUT means that you send the new representation of a resource (identified by its URI). If this resource does not exists, you create it with the provided representation. If it exists you replace its current representation. POST does not have such a precise definition, and then can be used to store file also.

best regards,
Thierry Boileau

Hi,
To store a file must I execute post or put method (if I understand well,
both work, but put method is better) ?

Please help
Thanks,
Regards.

Yannick

2008/4/22, Yannick PIERSON <[EMAIL PROTECTED]>:
Hi,
I don't understand why it doesn't work. I try many examples (for example
in a previous message with put method).

HttpClient client = new HttpClient();
Credentials credentials = new NTCredentials("user", "pwd", "homecomputer
", "WORKGROUP");
HttpState state = client.getState();
state.setCredentials(null, null, credentials);

PostMethod httppost = new PostMethod("http://computer_name/webdav_acces";);
// Is it the good path ?????????????????????????????

File file = new File("c:\\temp\\my_pdf.pdf");
httppost.setRequestEntity(new InputStreamRequestEntity(new
FileInputStream(file), file.length()));
// httppost.setContentChunked(true);

client.executeMethod(httppost);

With this code I get this error :
org.apache.commons.httpclient.ProtocolException: Unbuffered entity
enclosing request can not be repeated.
        at
org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:487)
        at
org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2114)
        at
org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096)
        at
org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
        at
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
        at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
        at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
        at javaapplication1.HttpClt.myPost(HttpClt.java:94)
        at javaapplication1.Main.main(Main.java:42)

Thanks in advance,
Regards.

Yannick




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

Reply via email to