Multiple Binary Attachement to Google Drive via Code & Merge Node

Describe the problem/error/question

I am trying to get attachments from emails, match the email to an account in GHL, find a folder for the account in my google drive and upload the attachments found in the email to the google drive folder. If a folder is not found, I am creating the folder and then trying to upload the same attachments.

I am using the code node to split out the binary data and returning single item for each file with a data key containing your binary file. I am then sending that to a merge node along with the id of my google drive folder to the merge node.

When trying to upload the data attachments to the id of the folder, I am unable to choose item 1 (where my attachments are from the merge node) and item 0 where my id is for the google drive folder.

What is the error message (if any)?

The name of the input field containing the binary file data must be set [item 0]

Please share your workflow

Share the output returned by the last node

NodeOperationError: The name of the input field containing the binary file data must be set at Object.getItemBinaryData

Information on your n8n setup

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

Welcome to the community @ppate2208 !

Tip for sharing information

Pasting your n8n workflow


Ensure to copy your n8n workflow and paste it in the code block, that is in between the pairs of triple backticks, which also could be achieved by clicking </> (preformatted text) in the editor and pasting in your workflow.

```
<your workflow>
```

That implies to any JSON output you would like to share with us.

Make sure that you have removed any sensitive information from your workflow and include dummy or pinned data with it!


Your merge configuration is not valid for your use case. Using “Append” mode implies separate items (one appended to the other in the array of items). You rather need setting it as “Combine” and match the apropriate fields to have both the ID and the binary combined in a single item.

Hi @ihortom . Thank you for your response! I have repasted the workflow code as you mentioned. Removed all ids and pasted between the quotes.

I then updated my merge node with ‘Combine’ as the mode.

When choosing the combine by field, I tested with Position first and it returned an array with 1 item.

As so:
[ { “id”: “”, “name”: “l”, “fileName”: “File_1.png” } ]

In the binary tab, only file 1 was displayed with variable name ‘data’

Since my other attachments were not returned I chose to combine by ‘All possible Combinations’. This gave me 2 items inside an array.

As so:
[ { “id”: " “, “name”: l”, “fileName”: " File_1.png" } , { “id”: " ", “name”: " “, “fileName”: " File_2.png” } ]

Binary tab displayed both attachments with a variable name data.

I then tested the upload node. As shown in the picture below:
image

The output returned was:

I’m not quite sure what I am doing wrong here. Should the array only return 1 item? If so, how would I be able to upload all the attachments and not just 1. Can the merge node return 1 item with both files?

Appreciate the help. Thanks in advance!

1 Like

The solution was to combine by all possible combinations and use ‘data’ as the binary input field name

2 Likes

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