Skip to content

Commit

Permalink
Modified the sample in the README file to match the new 'write' metho…
Browse files Browse the repository at this point in the history
…d in the resources
  • Loading branch information
AdrienCastex committed May 31, 2017
1 parent 92903ff commit 9f1b0f0
Showing 1 changed file with 34 additions and 32 deletions.
66 changes: 34 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,45 +113,47 @@ const server = new webdav.WebDAVServer({
// Create a virtual file
var file = new webdav.VirtualFile('testFile.txt');
// Set the content of the virtual file
file.write('The content of the virtual file.', false, (e) => {
if(e)
throw e;

// Add the virtual resources to the root folder
// Note that you can add resources even when the
// server is running
server.addResourceTree({
r: new webdav.VirtualFolder('testFolder'),
c: [{
r: new webdav.VirtualFolder('test1'),
c: new webdav.VirtualFile('test2')
}, {
r: new webdav.VirtualFolder('test2'),
file.write(true, (e, writer) => {
if(e) throw e;

writer.end('The content of the virtual file.', (e) => {
if(e) throw e;

// Add the virtual resources to the root folder
// Note that you can add resources even when the
// server is running
server.addResourceTree({
r: new webdav.VirtualFolder('testFolder'),
c: [{
r: new webdav.VirtualFolder('test1'),
c: new webdav.VirtualFile('test2')
},{
}, {
r: new webdav.VirtualFolder('test2'),
c: new webdav.VirtualFile('test2')
c: [{
r: new webdav.VirtualFolder('test1'),
c: new webdav.VirtualFile('test2')
},{
r: new webdav.VirtualFolder('test2'),
c: new webdav.VirtualFile('test2')
}]
}]
}]
}, e => {
if(e)
throw e;

// Start the server
server.start(httpServer => {
console.log('Server started with success on the port : ' + httpServer.address().port);

// [...]

// Stop the server
server.stop(() => {
console.log('Server stopped with success!');
})
}, (e) => {
if(e) throw e;

// Start the server
server.start(httpServer => {
console.log('Server started with success on the port : ' + httpServer.address().port);

// [...]

// Stop the server
server.stop(() => {
console.log('Server stopped with success!');
})
});
});
});
}
})
```

In this example, the resource tree will be the following :
Expand Down

0 comments on commit 9f1b0f0

Please sign in to comment.