Read a file and multiplex with json

Describe the issue/error/question

Currenlty i try to send a email. I need json data (for text) and binary data (for attach).
I tried to multiplex (Merge multiplex not works it all for binary data) with a function node:

const bin = $node.Pdf.binary.data
for (item of items) {
  item.binary = {};
  item.binary.data = bin;
}
console.log(items);
return items;

What is the error message (if any)?

Binary not contains binary data. Only File meta data

Please share the workflow

Currently Impossible. Because there are some internal data in the workflow.

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 0.194.0
  • Database you’re using (default: SQLite): postgres
  • Running n8n with the execution process [own(default), main]: main
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: npm

Hi @lublak, do you have any example workflow using which the “Merge multiplex doesn’t work with binary data” can be reproduced?

I just gave the below workflow a go and got four items, each with my example file as a binary property:

As for manipulating binary data using the Function node, you’re probably looking for something like this:

No binary data comes in, but all items leave the Function node with binary data:

I will provide an example tomorrow.
But for me it shows also binary data in the browser. If I click on the “view” button it shows an error because it’s empty.
I hope it’s fine if I send an reproducible example tomorrow.

Probably worth mentioning that I was using N8N_DEFAULT_BINARY_DATA_MODE=filesystem when testing this. Perhaps you can confirm whether you are using a different setting here when posting your example.

1 Like

Okay. Multiplex magically works today.
I don’t know why it didn’t work yesterday.
I can’t get the function node to work (even though I don’t need it now). Still, it would be useful here to know what I’m doing wrong.
Btw. i am using default settings for N8N_DEFAULT_BINARY_DATA_MODE

image

Just another question: N8N_DEFAULT_BINARY_DATA_MODE
How to set it in the json config file? I am not using env vars.

Hi @lublak, you can set N8N_DEFAULT_BINARY_DATA_MODE in a JSON config file like so:

{
	"binaryDataManager": {
		"mode": "filesystem"
	}
}

You can check out the exact schema for all environment variables here: n8n/schema.ts at 97cd564f7b4c5ba1472e517e0d54897b2cabcc26 · n8n-io/n8n · GitHub

As for your first previous question I think (though haven’t confirmed this) binary data isn’t supposed to be accessed across different nodes. With N8N_DEFAULT_BINARY_DATA_MODE=filesystem the binary item is however a simple reference to a file on your hard drive, so I wonder if this is what has made it work in the end.

Either way, the Merge node should simplify things a lot here, so I am glad to hear this works.

1 Like