It was mkcolMethod that I had been looking for.
Cheers
Luke. -----
On 27 Apr 2004, at 17:43, Amr Elssamadisy wrote:
This is a test that I have written that I think does what you want - hope it helps.
/**
* Expecting user name of test/test to allow a correct login and give
* write permissions
* @throws Exception
*/
public void testWebdavWriteWithNewDirectory() throws Exception{
long begin = System.currentTimeMillis();
homeUrl.setUserinfo("test","test");
WebdavResource res = new WebdavResource(homeUrl);
assertTrue(res.exists());
try{
boolean success = res.mkcolMethod("/testDir");
assertTrue(res.getStatusMessage(),success);//write an dir success = res.putMethod("/testDir/testFile","");
assertTrue(res.getStatusMessage(),success);//write an empty file }
finally{
res.deleteMethod(""); }
long end = System.currentTimeMillis(); System.out.println("seconds running: "+ (end-begin)/1000);
}
luke noel-storr wrote:
Hi,
Using the slide Java client I'm trying to create a new file which I want to
create in a directory that doesn't yet exist.
I've tried several things, but can't get any to work.
Say for example I want to create a new file at the URL:
http://localhost:8080/slide/files/data/bob/newfile
and the directory 'bob' does not yet exist, how would I go about doing this?
here is an example of code I have tried:
HttpURL httpURL = new HttpURL("http://localhost:8080/slide/files/data/bob/newfile");
wdr = new WebdavResource(httpURL, credentials, WebdavResource.NOACTION,
DepthSupport.DEPTH_0);
if (wdr.putMethod(bytes))
{
System.out.println("YES!!");
}
else
{
System.out.println("NO!!");
}
I have also tried:
HttpURL httpURL = new HttpURL("http://localhost:8080/slide/files/data/");
wdr = new WebdavResource(httpURL, credentials, WebdavResource.NOACTION,
DepthSupport.DEPTH_0);
if (wdr.putMethod("bob/newfile", bytes))
{
System.out.println("YES!!");
}
else
{
System.out.println("NO!!");
}
Which also didn't work (and the directory 'data' does exist).
Any pointers, I'm kind of lost here?
Also, out of interest (and it may be related), how would I create a new empty
directory?
Cheers
Luke. -----
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- Amr Elssamadisy
Developer,Researcher,Student (In no particular order...)
tel: (413) 207-1225 email: [EMAIL PROTECTED]
--------------------------------------------------------------------- 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]