Writing a WebDAV Client

Hi,

I am trying to write a WebDAV client using the http and Webdav librarys that come with Slide. I have the following code. This does create a file in the Webdav directory but the file size is Zero.

String dest = getPath();
String src = “c:/filetoupload.txt”;

File file = new File(src);
System.out.println(file.length());

if (file.exists()) {
System.out.print(“Uploading '” + src +
“’ to '” + dest + “’: “);
if (webdavResource.putMethod(dest+”/filea.txt”, file)) {
System.out.println(“succeeded.”);
} else {
System.err.println(“failed.”);
System.err.println(
webdavResource.getStatusMessage());
}
} else
System.err.println
(“Warning: File not exists”);


Regards
Pushparajan

Hi Pushparajan,

I 've the same problem with Slide WebDav Client.
Did you find any solution for this problem?
Thanks and regards,

Esteban

Hello,

in our environment we were successful with following piece of code:


String aFileName = ?A FILE NAME?;
File input = new File(aFileName);
if (!input.exists()) throw new Exception(“File " + aFileName + " does not exist”);
method.setHeader(“Content-Length”, “”+input.length());
method.sendData(input);



Best regards

Juergen

Hi Juergen, thank you very much for your reply. I have solved the problem. I modified the Side.java . I changed the constructor of the File method.
Best regards

Code:

//Change the src.indexOf
if ((count == 2 && src.indexOf(“http:”) >=0) ||
count == 1 && dest.indexOf(":") > 1)


//Old!
// File file = new File(dir.getCanonicalPath(), src);

//New!!
File file = new File(src);