How to get binary data from a previously processed node?

Hi everyone, I am currently getting used to the way n8n does things. The one issue I struggle the most is about binary data.

The way I found from documentation is to use getBinaryData() to get binary data in function node. However, it won’t work after any ‘string or json returning’ node. For an example,

Noted that the binary file is not in the output and can’t be used anymore.

The other way I found from the documentation is getBinaryDataBuffer(), but it doesn’t work it seems for the same reason.

And $node["XXX"].binary.keyname doesn’t seem to work, and I am told in the documentation to avoid accessing it like this directly.

Is there anything I am missing here? It seems very weird that I can’t use the binary data anymore after any JSON or String returning node.

1 Like

Hi @Ronald_Lam, Welcome to the community. You may want to try this function node and see if it does what you are trying to accomplish. My understanding is that is should call all data in the specified node.

Welcome to the community @Ronald_Lam!

Sorry not at the computer right now, so can not post an example. But what you can do is to merge the binary data back in the flow again by using the Merge-Node in mode “Merge by Index”.

Hope that is helpful!

Thank you so much for the replies. I will use a merge node for now.

But I think it’s very common to process data and download multiple binary files at different points within a workflow, and send them all as email attachments in the end etc… so I hope this kind of merge can be implemented and can be used on the setting tab of all nodes directly.

5 Likes

Hi @jan ,

I’ve got the same issue and also solved it via a Merge-node. But now since v1 I’m having issues because the behaviour of the Merge-node has changed and is now always executed, even when there is only 1 input set. As I’m having a lot of conditional branches, this is not the desired behaviour. Any idea how to solve this?

Thanks
Cadish

You should be able to change the execution order back to legacy for now. See if that helps. Go into the workflow settings and edit execution order:

Tried that, but didn’t help. Seems that if input 1 has an input, the node is always executed. Which is not the case for input 2. Changing the inputs solved my issue…

1 Like