From 186b402d0715794e10d196811a04abea4fba5e57 Mon Sep 17 00:00:00 2001 From: Peter Svensson Date: Wed, 22 Apr 2020 20:03:17 +0200 Subject: [PATCH] fixed bug in storage module --- package.json | 2 +- storage/storage-list.js | 3 ++- storage/storage-read.js | 4 ++-- storage/storage-write.js | 7 ++++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 77c14d9..85be533 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-contrib-firebase-admin", - "version": "1.1.17", + "version": "1.1.18", "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 10228c0..b0c8bf4 100644 --- a/storage/storage-list.js +++ b/storage/storage-list.js @@ -10,7 +10,8 @@ module.exports = function(RED) { if(config.cred){ let c = RED.nodes.getNode(config.cred) this.admin = c.admin - this.storage = c.storage + let global = this.context().global + this.storage = c.storage || global.get('cloud-storage') this.bucket = config.bucket || c.bucket this.path = config.path } diff --git a/storage/storage-read.js b/storage/storage-read.js index db91a13..458b313 100644 --- a/storage/storage-read.js +++ b/storage/storage-read.js @@ -10,8 +10,8 @@ module.exports = function(RED) { if(config.cred){ let c = RED.nodes.getNode(config.cred) this.admin = c.admin - this.storage = c.storage - storage = this.storage + let global = this.context().global + this.storage = c.storage || global.get('cloud-storage') this.bucket = config.bucket || c.bucket this.path = config.path diff --git a/storage/storage-write.js b/storage/storage-write.js index e43fc4b..595ac8f 100644 --- a/storage/storage-write.js +++ b/storage/storage-write.js @@ -9,7 +9,8 @@ module.exports = function(RED) { if(config.cred){ let c = RED.nodes.getNode(config.cred) this.admin = c.admin - this.storage = c.storage + let global = this.context().global + this.storage = c.storage || global.get('cloud-storage') this.bucket = config.bucket || c.bucket this.path = config.path /* @@ -21,7 +22,7 @@ module.exports = function(RED) { } - node.on('input', function(msg) { + 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 @@ -40,7 +41,7 @@ module.exports = function(RED) { // File written successfully. msg.payload={success:true, filename: path} } else { - console.log('cloud storage write error: '+err) + console.log('cloud storage write error: '+JSON.stringify(err)) msg.payload ={success:false, filename: path} } node.send(msg)