refactord, tidied up, added icon for storage and a new node for writing buffers to storage files

This commit is contained in:
Peter Svensson
2019-07-02 20:43:04 +02:00
parent ae90a7c225
commit df5b5c8e82
26 changed files with 120 additions and 16 deletions

40
storage/storage-read.js Normal file
View File

@ -0,0 +1,40 @@
let oldpath
module.exports = function(RED) {
function FirebaseAdmin(config) {
RED.nodes.createNode(this, config);
var node = this;
if(config.cred){
let c = RED.nodes.getNode(config.cred)
this.admin = c.admin
this.storage = c.storage
this.bucket = config.bucket || c.bucket
this.path = config.path
}
//console.log('configuring storage-read to listen for messages')
node.on('input', function(msg) {
if(msg && msg.payload){
let path = msg.payload.path || this.path
let bucket = msg.payload.bucket || this.bucket
console.log('storage-read reading from bucket "'+bucket+'" path "'+path+'"')
this.storage
.bucket(bucket)
.file(path).download().then((file)=>{
console.log('storage-read got file')
//console.dir(file)
node.send({payload:file})
})
}
}.bind(this));
}
RED.nodes.registerType("storage-read", FirebaseAdmin);
}