Multiple binary - access with json expression filename

Describe the problem/error/question

Follow up to this

I have 3 binary files coming from the input node:

-data
-data_overlay
-firstname_lastname_ig

I want to JUST target and pass along the the last binary using this expression:

{{ $binary[$json.property_first_name + ‘_’ + $json.property_last_name + ‘_IG’].fileName }}

But that returns undefined.

If I use this expression to just target that specific binary:

{{ $binary.Alex_Jack_IG.fileName }}

It returns this “Alex _Jack_IG” which is good, but it’s not always that Alex_Jack, it can be Sam_Jack for example (different names).

Any thouhgts on how I can use $binary and access a specific fileName with json expressions in brackets?

What is the error message (if any)?

I get “undefined”.

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • **n8n version:**1.38
  • Database (default: SQLite):
  • **n8n EXECUTIONS_PROCESS setting (default: own, main):**own
  • **Running n8n via (Docker, npm, n8n cloud, desktop app):**Docker
  • Operating system:

If the binary filed is dynamic, you can get it via the object keys method:

{{ $binary[Object.keys($binary)[0]].fileName }}

that worked. thx

What if I want to dynamically target the binary file not based on the order/number (e.g. [0] ) but base on the name (e.g. [$json_first_name]?

That [0] is not the number, it means to take the first key from the list of keys.
You can use the name as well:

{{ $binary[$json_first_name].fileName }}

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.