How do I convert the buffer object in this screenshot:
back to a CSV file:
where is the buffer coming from? What node is generating that data?
PS, you could use
msg.payload = msg.payload.toString() return msg
but it may not be necessary (need to see your flow and what generates the data)
This error shows when i put msg.payload.toString() -
Here is my flow. The buffer comes from firebase storage. When I upload my file as a single buffer object or a utf string the output from the read node stays the same
The change node just takes the payload from an array to payload. Next to the buffer in the debug window i can change it from row to string which shows the correct values but when i write this buffer object to a file it does not write it correctly. so i need to change
the buffer to a string...
If you take a file node and the output will be a single buffer object it gives the exact same msg in the debug as from that storage read node. so how can i convert that buffer to a string ?
attach a debug node to the output of "storage-read" - its no good showing anyone that is BAD after processing.
In your error "cannot read property
toString it could be because msg.payload is empty (hence needing you to put a debug after "storage-read")
PS what node is that "storage-read"? please show me in flow library
When i try to use the node-red-contrib-firebase-storage my nodes didnt want to connect to firebase and no one could help me. So i tried this one. This one works but after every third deploy of flows the nodes stop working. something to do with credentials. then i need to restart again.
so your data is a buffer (before you break it in the change node).
So get rid of the change node and put a function node in its place & put the code I said in it.
Heres the proof...
firebase node >> function node >> debug node
function node code...
msg.payload = msg.payload.toString() return msg;
PS, i dont use that node - does it not have an option to return something other than a buffer?
When i deploy that function node the error still appears but when i restart the IOT2000 with the function node connected it works. Mindblown.... SO now everytime i need to restart the thing which takes ages..
When im finished with this project hopefully it works continuously after the first startup
One more issue please. Under every array there is a "name" which i want to retrieve. I know how to retrieve a name from a specific array but how can i retrieve all of them
So payload is an object with a files property which is an array. You could do loop through
msg.payload.files and push
msg.payload.files[x].name to another array (where x is an integer incrementing from 0 to
Ps, there will also be a few other ways including JSONata and a change node - but I'm no up to speed on that.
You're close but yes you are doing something wrong - Inside the loop, you are overwriting
msg.payload on the first iteration with the
name from element 0. (I.e. you're killing the array)
Try creating a temporary var array above the loop to hold the names.
var names = 
Then inside the loop....
And lastly return the array
msg.payload = names return msg
Awesome. Thank you so much
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.