fixed bug in storage module

This commit is contained in:
Peter Svensson
2020-04-22 20:03:17 +02:00
parent 603029bc87
commit 186b402d07
4 changed files with 9 additions and 7 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "node-red-contrib-firebase-admin", "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.", "description": "A node-red module that wraps the server-side admin SDK of firebase, firestore, et.c.",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

View File

@ -10,7 +10,8 @@ module.exports = function(RED) {
if(config.cred){ if(config.cred){
let c = RED.nodes.getNode(config.cred) let c = RED.nodes.getNode(config.cred)
this.admin = c.admin 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.bucket = config.bucket || c.bucket
this.path = config.path this.path = config.path
} }

View File

@ -10,8 +10,8 @@ module.exports = function(RED) {
if(config.cred){ if(config.cred){
let c = RED.nodes.getNode(config.cred) let c = RED.nodes.getNode(config.cred)
this.admin = c.admin this.admin = c.admin
this.storage = c.storage let global = this.context().global
storage = this.storage this.storage = c.storage || global.get('cloud-storage')
this.bucket = config.bucket || c.bucket this.bucket = config.bucket || c.bucket
this.path = config.path this.path = config.path

View File

@ -9,7 +9,8 @@ module.exports = function(RED) {
if(config.cred){ if(config.cred){
let c = RED.nodes.getNode(config.cred) let c = RED.nodes.getNode(config.cred)
this.admin = c.admin 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.bucket = config.bucket || c.bucket
this.path = config.path 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){ if(msg && msg.payload){
let path = msg.payload.path || msg.path|| this.path let path = msg.payload.path || msg.path|| this.path
let bucket = msg.payload.bucket || msg.bucket || this.bucket let bucket = msg.payload.bucket || msg.bucket || this.bucket
@ -40,7 +41,7 @@ module.exports = function(RED) {
// File written successfully. // File written successfully.
msg.payload={success:true, filename: path} msg.payload={success:true, filename: path}
} else { } else {
console.log('cloud storage write error: '+err) console.log('cloud storage write error: '+JSON.stringify(err))
msg.payload ={success:false, filename: path} msg.payload ={success:false, filename: path}
} }
node.send(msg) node.send(msg)