addad missing option to set directory in incoming message for WebDAV list

This commit is contained in:
kuehnelbs
2018-04-29 21:07:22 +02:00
parent 4a061da9d4
commit 1870810b57

View File

@ -134,11 +134,14 @@ module.exports = function(RED) {
node.on('input', function(msg) { node.on('input', function(msg) {
const webDavUri = node.server.address + '/remote.php/webdav/' const webDavUri = node.server.address + '/remote.php/webdav/'
const client = webdav(webDavUri, node.server.credentials.user, node.server.credentials.pass) const client = webdav(webDavUri, node.server.credentials.user, node.server.credentials.pass)
let directory = '/' let directory = ''
if (node.directory && node.directory.length) { if (msg.directory) {
directory += node.directory + '/' directory = '/' + msg.directory
directory = directory.replace('//', '/') } else if (node.directory && node.directory.length) {
directory = '/' + node.directory
} }
directory = directory.replace('//', '/')
client.getDirectoryContents(directory) client.getDirectoryContents(directory)
.then(function (contents) { .then(function (contents) {
node.send({'payload': contents}) node.send({'payload': contents})
@ -159,6 +162,7 @@ module.exports = function(RED) {
node.on('input', function(msg) { node.on('input', function(msg) {
const webDavUri = node.server.address + '/remote.php/webdav/' const webDavUri = node.server.address + '/remote.php/webdav/'
const client = webdav(webDavUri, node.server.credentials.user, node.server.credentials.pass) const client = webdav(webDavUri, node.server.credentials.user, node.server.credentials.pass)
let filename = ''
if (msg.filename) { if (msg.filename) {
filename = '/' + msg.filename filename = '/' + msg.filename
} else if (node.filename && node.filename.length) { } else if (node.filename && node.filename.length) {