fixed bug in storage module
This commit is contained in:
@ -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": {
|
||||||
|
|||||||
@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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
|
||||||
|
|
||||||
|
|||||||
@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user