Skip to content

Commit 0beebbe

Browse files
committed
Modified the sample to use the new way to create the resource tree (with 'addResourceTree')
1 parent bda6e6c commit 0beebbe

File tree

1 file changed

+29
-32
lines changed

1 file changed

+29
-32
lines changed

README.md

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
* Authentication
2525
* Privileges
2626
* Control the response body type
27-
* Persistence
2827
* Persistence
2928
* Overview
3029
* Example
@@ -113,39 +112,37 @@ var file = new webdav.VirtualFile('testFile.txt');
113112
// Set the content of the virtual file
114113
file.content = 'The content of the virtual file.';
115114

116-
// Add the virtual file to the root folder
117-
server.rootResource.addChild(file, e => {
115+
// Add the virtual resources to the root folder
116+
// Note that you can add resources even when the
117+
// server is running
118+
server.addResourceTree({
119+
r: new webdav.VirtualFolder('testFolder'),
120+
c: [{
121+
r: new webdav.VirtualFolder('test1'),
122+
c: new webdav.VirtualFile('test2')
123+
}, {
124+
r: new webdav.VirtualFolder('test2'),
125+
c: [{
126+
r: new webdav.VirtualFolder('test1'),
127+
c: new webdav.VirtualFile('test2')
128+
},{
129+
r: new webdav.VirtualFolder('test2'),
130+
c: new webdav.VirtualFile('test2')
131+
}]
132+
}]
133+
}, e => {
118134
if(e)
119135
throw e;
120-
121-
// Create a virtual folder
122-
var folder = new webdav.VirtualFolder('testFolder');
123-
server.rootResource.addChild(folder, e => {
124-
if(e)
125-
throw e;
126-
127-
var file2 = new webdav.PhysicalFile('/home/testFile2.txt');
128-
folder.addChild(file2, e => {
129-
if(e)
130-
throw e;
131-
132-
var folder2 = new webdav.PhysicalFolder('/home/testFolder2');
133-
folder.addChild(folder2, e => {
134-
if(e)
135-
throw e;
136-
137-
// Start the server
138-
server.start();
139-
140-
// [...]
141-
142-
// Stop the server
143-
server.stop(() => {
144-
console.log('Server stopped with success!');
145-
})
146-
});
147-
});
148-
});
136+
137+
// Start the server
138+
server.start();
139+
140+
// [...]
141+
142+
// Stop the server
143+
server.stop(() => {
144+
console.log('Server stopped with success!');
145+
})
149146
});
150147
```
151148

0 commit comments

Comments
 (0)