How to reference binary data

Describe the problem/error/question

How can I reference a binary file (specifically data) that was output from the second node (HTTP Request) in the 7th node (Google Drive → Upload File)?

For backup purposes, I also created a copy of the binary data as backupBinary in the 3rd node (Code in JavaScript), using the following code:

javascript code


return items.map(item => {
  return {
    json: item.json,
    binary: {
      ...item.binary,
      backupBinary: item.binary?.data,
    }
  };
});

Visually, it looks like the backupBinary was created correctly.

The reason I did this was because the next node (Extract from File) seems to convert the binary to base64, and I assumed this causes the original binary to be removed — which is why I tried to preserve it as backupBinary.

However, after doing more research, I now believe that converting to base64 might not actually remove the binary field, so maybe this backup is unnecessary.

What I tried:
In the Google Drive → Upload file node, I set the “Input Data Field Name” using an expression:

{{$node["HTTP Request"].binary["data"]}}

What is the error message (if any)?

This operation expects the node’s input data to contain a binary file ‘[object Object]’, but none was found [item 0]

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

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

Hey, accessing binary like that is a bit weird, here is the correct way:

{{ $('HTTP Request').item.binary.keys()[0] }}

Hope this helps!

1 Like

The way to bring the binary from the second node to the input of the last node is

  1. save the binary and load it again just before you need it, or
  2. merge the output os the 2nd node and the AI Agent node with Merge node

Thank you so much!

This method didn’t work for me, but I really appreciate your comment!

I was able to solve the issue by merging the output of the second node and the AI Agent node using a Merge node.

Please mark the answer which helped you as Solution.
Cheers!

1 Like

Thank you so much!
I was able to solve it by merging the outputs of the 2nd node and the AI Agent node with a Merge node!

  1. Check Binary Name: Make sure the binary field name from the HTTP Request node is actually data. If not, check the output to get the correct name.
  2. Use Backup Binary: Since you’re saving the binary as backupBinary, use that in your Google Drive node like this:

{{$node[“Code”].binary[“backupBinary”]}}

3.Set Node for Debugging: If unsure, add a Set node to manually pass the binary to the next node and use that as reference.

This should get your binary data passed correctly to Google Drive

This is the way. Thank you, I spent hours trying to fix this!