diff --git a/package.json b/package.json index fcf9d3c..999e314 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-contrib-firebase-admin", - "version": "1.1.19", + "version": "1.1.20", "description": "A node-red module that wraps the server-side admin SDK of firebase, firestore, et.c.", "main": "index.js", "scripts": { diff --git a/storage/storage-list.js b/storage/storage-list.js index b0c8bf4..dcb1e6a 100644 --- a/storage/storage-list.js +++ b/storage/storage-list.js @@ -10,8 +10,7 @@ module.exports = function(RED) { if(config.cred){ let c = RED.nodes.getNode(config.cred) this.admin = c.admin - let global = this.context().global - this.storage = c.storage || global.get('cloud-storage') + this.config = c; this.bucket = config.bucket || c.bucket this.path = config.path } @@ -20,6 +19,8 @@ module.exports = function(RED) { //console.log('configuring storage-list to listen for messages') node.on('input', function(msg) { if(msg && msg.payload){ + let global = this.context().global + this.storage = this.config.storage || global.get('cloud-storage') let path = msg.payload.path || this.path let bucket = msg.payload.bucket || this.bucket console.log('storage-list listing files from bucket "'+bucket+'" path "'+path+'"') diff --git a/storage/storage-read.js b/storage/storage-read.js index d86393f..06d8ba8 100644 --- a/storage/storage-read.js +++ b/storage/storage-read.js @@ -9,6 +9,7 @@ module.exports = function(RED) { if(config.cred){ let c = RED.nodes.getNode(config.cred) + this.config = c; this.admin = c.admin let global = this.context().global this.storage = c.storage || global.get('cloud-storage') @@ -18,15 +19,16 @@ module.exports = function(RED) { console.log('config is '+config) } - let global = this.context().global - this.storage = global.get('cloud-storage') - console.log('* storage-read set this.storage to '+this.storage) + //console.log('configuring storage-read to listen for messages') node.on('input', function(msg) { if(msg && msg.payload){ let path = msg.payload.path || msg.path || this.path let bucket = msg.payload.bucket || msg.bucket || this.bucket + let global = this.context().global + this.storage = global.get('cloud-storage') + console.log('* storage-read set this.storage to '+this.storage) console.log('------------------------------ storage-read reading from bucket "'+bucket+'" path "'+path+'" this.storage = '+this.storage) if(msg.payload.files && msg.payload.files.length > 0){ console.log('--reading from files') diff --git a/storage/storage-write.js b/storage/storage-write.js index 595ac8f..4799311 100644 --- a/storage/storage-write.js +++ b/storage/storage-write.js @@ -7,10 +7,10 @@ module.exports = function(RED) { if(config.cred){ - let c = RED.nodes.getNode(config.cred) + let c = RED.nodes.getNode(config.cred); + this.config = c; this.admin = c.admin - let global = this.context().global - this.storage = c.storage || global.get('cloud-storage') + this.bucket = config.bucket || c.bucket this.path = config.path /* @@ -24,6 +24,8 @@ module.exports = function(RED) { node.on('input', function(msg) { if(msg && msg.payload){ + let global = this.context().global + this.storage = this.config.storage || global.get('cloud-storage') let path = msg.payload.path || msg.path|| this.path let bucket = msg.payload.bucket || msg.bucket || this.bucket let contents = msg.payload.contents || msg.payload