-
Notifications
You must be signed in to change notification settings - Fork 67
Examples
Adrien Castex edited this page Jun 16, 2017
·
3 revisions
This page is not completed yet.
You can find more examples here.
const webdav = require('webdav-server');
const um = new webdav.SimpleUserManager();
const user = um.addUser('myUsername', 'myPassword', false);
const pm = new webdav.SimplePathPrivilegeManager();
pm.setRights(user, '/', [ 'all' ]);
const server = new webdav.WebDAVServer({
isVerbose: true,
userManager: um,
privilegeManager: pm
});
server.start(() => console.log('READY'));
const webdav = require('webdav-server');
const server = new webdav.WebDAVServer({
isVerbose: true,
autoSave: {
treeFilePath: 'data.json',
tempTreeFilePath: 'data.tmp.json',
onSaveError: () => {
console.log('SAVE ERROR');
},
streamProvider: (stream, cb) => {
cb(stream.pipe(zlib.createGzip())); // useless because the argument 'stream' is already a GZip stream
}
}
});
server.start(() => console.log('READY'));
const webdav = require('webdav-server'),
zlib = require('zlib'),
fs = require('fs');
const server = new webdav.WebDAVServer(/* [...] */);
const stream = zlib.createGunzip();
try
{
fs.createReadStream('data.json').pipe(stream);
let data = '';
stream.on('data', (chunk) => {
data += chunk.toString();
})
stream.on('end', () => {
this.server.load(JSON.parse(data), [
new webdav.RootFSManager(),
// [...]
], e => {
if(e) throw e;
server.start(() => console.log('READY'));
})
})
stream.on('error', () => {
console.log('Could not load.');
server.start(() => console.log('READY'));
})
}
catch(ex)
{
console.log('Could not load.');
server.start(() => console.log('READY'));
}
const webdav = require('webdav-server');
const server = new webdav.WebDAVServer();
server.addResourceTree({
r: new webdav.VirtualFolder('testFolder'), // /testFolder
c: [{
r: new webdav.VirtualFolder('test1'), // /testFolder/test1
c: new webdav.VirtualFile('test2') // /testFolder/test1/test2
}, {
r: new webdav.VirtualFolder('test2'), // /testFolder/test2
c: [{
r: new webdav.VirtualFolder('test1'), // /testFolder/test2/test1
c: new webdav.VirtualFile('test2') // /testFolder/test2/test1/test2
},{
r: new webdav.VirtualFolder('test2'), // /testFolder/test2/test2
c: new webdav.VirtualFile('test2') // /testFolder/test2/test2/test2
}]
}]
}, (e) => {
if(e) throw e;
server.start(() => console.log('READY'));
});
- Home
- Version 2
- Install
- Quick Start Guide
- Examples
- Concepts
- User concepts
- Server concepts
- Customizing
- Version 1 [Obsolete]
- Install
- Quick Start Guide
- Examples
- Features
- Resource concepts
- User concepts
- Server concepts
- Customizing
- Project