I want to access binary data in the code-node, wich gets passed through from outlook. It appears I can not access a helper function on our cloud instance; this.helpers.getBinaryDataBuffer, no matter what I tried so far.
Thanks for pointing that out, apparently I was sloppy when creating the snippet, the 2nd attiribute “data” is indeed set as “data”…
…litteraly copying the code block from your answer also throws an “Unknown error”… but on n8n.cloud only. Doesn’t matter if binary is passed along to the code node or not.
The same workflow on our internal community node outputs different binary data, where a “data” attribute containing base64 encoded data is set, but an “id” is missing. So I just started working with the “data” attribute directly.
(getBinaryDataBuffer here: Cannot read properties of undefined (reading ‘id’))
However that means I could not copy over the workflow from self hosted to cloud and vice-versa, wich gave me a small headache initially.
Anyway it would be nice to figure out a solution for n8n.cloud.
Can you reproduce the error yourself?
We have a mostly fresh instance.
@axp_om The error is definitely something we could improve here. However, you are using the getBinaryDataBuffer wrong. Based on the docs, the first argument is in the item index (e.g. $itemIndex if you are using “Run once for each item”), and second parameter is the property name where the binary file is stored (e.g. data if you are reading the data with ReadBinaryFile node):
That makes more sense, the helper function accesses the $input binary at index 0.
But on the cloud I don’t get “data” within the binary object, rather a filesystem-id.
=> I converted the binary to a base64 string and was able to work with it afterwards with JSON, to extract am XML file from within the PDF. (ZUGFeRD)
It would be quite helpful to have more options with the code node and an easier debugging experience. But I suppose there’s not much I can do now.
Is there an aproximate ETA when we can expect an updated stable version?
Right. So the reason why the data property in cloud contains a filesystem-id while the self-hosted version contains the base64 encoded data, is that in cloud the N8N_BINARY_DATA_MODE is set to filesystem, while the default mode is default (yes it’s a bit confusing name). The default mode is deprecated and is going to be removed in a future version. I suggest you set N8N_BINARY_DATA_MODE=filesystem so the behaviour is the same in both cloud and self-hosted, and it will work in the future as well.
With this mode the data is not provided directly in the binary property, and you need to use the this.helpers.getBinaryDataBuffer method to get it.