-
Notifications
You must be signed in to change notification settings - Fork 67
Quick Start Guide [v2]
Adrien Castex edited this page Jan 22, 2018
·
4 revisions
You can find the install/import steps here.
// Typescript
import { v2 as webdav } from 'webdav-server'
// Javascript
const webdav = require('webdav-server').v2;
const server = new webdav.WebDAVServer({
port: 1900
});
server.afterRequest((arg, next) => {
console.log('>>', arg.request.method, arg.fullUri(), '>', arg.response.statusCode, arg.response.statusMessage);
next();
})
server.start(httpServer => {
console.log('Server started with success on the port : ' + httpServer.address().port);
});
// TypeScript
import { v2 as webdav } from 'webdav-server'
// Javascript
const webdav = require('webdav-server').v2;
const server = new webdav.WebDAVServer();
server.rootFileSystem().addSubTree(server.createExternalContext(), {
'folder1': { // /folder1
'file1.txt': webdav.ResourceType.File, // /folder1/file1.txt
'file2.txt': webdav.ResourceType.File // /folder1/file2.txt
},
'file0.txt': webdav.ResourceType.File // /file0.txt
})
server.start(httpServer => {
console.log('Server started with success on the port : ' + httpServer.address().port);
});
// TypeScript
import { v2 as webdav } from 'webdav-server'
// Javascript
const webdav = require('webdav-server').v2;
const server = new webdav.WebDAVServer({
autoSave: { // Will automatically save the changes in the 'data.json' file
treeFilePath: 'data.json'
}
});
// Try to load the 'data.json' file
server.autoLoad((e) => {
if(e)
{ // Couldn't load the 'data.json' (file is not accessible or it has invalid content)
server.rootFileSystem().addSubTree(server.createExternalContext(), {
'folder1': { // /folder1
'file1.txt': webdav.ResourceType.File, // /folder1/file1.txt
'file2.txt': webdav.ResourceType.File // /folder1/file2.txt
},
'file0.txt': webdav.ResourceType.File // /file0.txt
})
}
server.start(() => console.log('READY'));
})
To see more, you are invited to visit the examples page.
- 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