Need help Extracting Images submitted via webhook

Hey, I’m new to n8n and had some question which should be fairly easy to answer hopefully. Appreciate any feedback or guidance.

Describe the problem/error/question

I am trying to extract images that I sent via webhook.
I can see the binary data coming in as data0 and data1 (2 images)
and I sent the JSON including some image_metadata which is a stringified list of fileName, size, type for each file.

I’m having an issue sending this information through Google Storage etc. I’m not sure what File Name and File Type should be.

I did this same thing using an n8n Trigger Form and all the images come under the same heading ‘data’ and that worked. Somehow I need to dynamically put some values in those fields.

What is the error message (if any)?

No error, just no output.

Please share your workflow

{
“nodes”: [
{
“parameters”: {
“inputDataFieldName”: “={{ $binary.data0 }}\n”,
“name”: “={{ $binary.data0.fileName }}”,
“driveId”: {
“__rl”: true,
“value”: “My Drive”,
“mode”: “list”,
“cachedResultName”: “My Drive”,
“cachedResultUrl”: “YOUR_URL”
},
“folderId”: {
“__rl”: true,
“value”: “”,
“mode”: “list”,
“cachedResultName”: “AppName”,
“cachedResultUrl”: “YOUR_URL”
},
“options”: {}
},
“type”: “n8n-nodes-base.googleDrive”,
“typeVersion”: 3,
“position”: [
2580,
-140
],
“id”: “”,
“name”: “Google Drive1”,
“credentials”: {
“googleDriveOAuth2Api”: {
“id”: “”,
“name”: “Google Drive account 2”
}
}
},
{
“parameters”: {
“documentId”: {
“__rl”: true,
“value”: “”,
“mode”: “list”,
“cachedResultName”: “MetaGen Verified Emails”,
“cachedResultUrl”: “YOUR_URL”
},
“sheetName”: {
“__rl”: true,
“value”: 84400000,
“mode”: “list”,
“cachedResultName”: “Verified”,
“cachedResultUrl”: “YOUR_URL”
},
“filtersUI”: {
“values”: [
{
“lookupColumn”: “Email”,
“lookupValue”: “={{ $json.body.email }}”
}
]
},
“options”: {
“returnFirstMatch”: false
}
},
“type”: “n8n-nodes-base.googleSheets”,
“typeVersion”: 4.6,
“position”: [
1660,
140
],
“id”: “”,
“name”: “Google Sheets”,
“alwaysOutputData”: false,
“credentials”: {
“googleSheetsOAuth2Api”: {
“id”: “”,
“name”: “Google Sheets account”
}
}
},
{
“parameters”: {
“workflowId”: {
“__rl”: true,
“value”: “”,
“mode”: “list”,
“cachedResultName”: “Email Verification”
},
“workflowInputs”: {
“mappingMode”: “defineBelow”,
“value”: {
“$json.email”: “={{ $(‘Webhook’).item.json.body.email }}”
},
“matchingColumns”: [
“$json.email”
],
“schema”: [
{
“id”: “$json.email”,
“displayName”: “$json.email”,
“required”: false,
“defaultMatch”: false,
“display”: true,
“canBeUsedToMatch”: true,
“type”: “string”,
“removed”: false
}
],
“attemptToConvertTypes”: false,
“convertFieldsToString”: true
},
“options”: {
“waitForSubWorkflow”: true
}
},
“type”: “n8n-nodes-base.executeWorkflow”,
“typeVersion”: 1.2,
“position”: [
2620,
360
],
“id”: “”,
“name”: “Execute Workflow”
},
{
“parameters”: {
“conditions”: {
“options”: {
“caseSensitive”: true,
“leftValue”: “”,
“typeValidation”: “strict”,
“version”: 2
},
“conditions”: [
{
“id”: “”,
“leftValue”: “={{ $json.Email }}”,
“rightValue”: “”,
“operator”: {
“type”: “string”,
“operation”: “notEmpty”,
“singleValue”: true
}
}
],
“combinator”: “and”
},
“options”: {}
},
“type”: “n8n-nodes-base.if”,
“typeVersion”: 2.2,
“position”: [
2600,
40
],
“id”: “”,
“name”: “If”
},
{
“parameters”: {
“mode”: “combine”,
“combineBy”: “combineAll”,
“options”: {}
},
“type”: “n8n-nodes-base.merge”,
“typeVersion”: 3.1,
“position”: [
2060,
40
],
“id”: “”,
“name”: “Merge”,
“alwaysOutputData”: true
},
{
“parameters”: {
“httpMethod”: “POST”,
“path”: “metagen”,
“responseMode”: “responseNode”,
“options”: {
“allowedOrigins”: “*”,
“binaryPropertyName”: “data”
}
},
“type”: “n8n-nodes-base.webhook”,
“typeVersion”: 2,
“position”: [
1200,
20
],
“id”: “”,
“name”: “Webhook”,
“webhookId”: “”
},
{
“parameters”: {
“fieldToSplitOut”: “=$binary”,
“include”: “allOtherFields”,
“options”: {}
},
“type”: “n8n-nodes-base.splitOut”,
“typeVersion”: 1,
“position”: [
2240,
40
],
“id”: “”,
“name”: “Split Out”
}
],
“connections”: {
“Google Drive1”: {
“main”: [

]
},
“Google Sheets”: {
“main”: [
[
{
“node”: “Merge”,
“type”: “main”,
“index”: 1
}
]
]
},
“Execute Workflow”: {
“main”: [

]
},
“If”: {
“main”: [
[
{
“node”: “Google Drive1”,
“type”: “main”,
“index”: 0
}
],
[
{
“node”: “Execute Workflow”,
“type”: “main”,
“index”: 0
}
]
]
},
“Merge”: {
“main”: [
[
{
“node”: “Split Out”,
“type”: “main”,
“index”: 0
}
]
]
},
“Webhook”: {
“main”: [
[
{
“node”: “Google Sheets”,
“type”: “main”,
“index”: 0
},
{
“node”: “Merge”,
“type”: “main”,
“index”: 0
}
]
]
},
“Split Out”: {
“main”: [
[
{
“node”: “If”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “”
}
}

(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: => [email protected]
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): => n8n cloud
  • Operating system:

Hey @Cori ,

Instead of {{$binary.data0}} you just need to enter data0 or data1 to make it work

1 Like

Hey mate, thanks a lot for your help. I have tried that before but here I’ll show you the output:

I guess the bigger question is that my upload form can upload many images, so the those 2 inputs on my Google Node needs to be dynamic, other than data0, data1 etc. I would expect something like data? or data${index} which also don’t seem to work.

Thanks!

No problem @Cori ,

Here you go, I have create a demo workflow for your reference, to show you how we can upload multiple attachments to the google drive.

How to upload Multiple attachments in google drive.

In this demo workflow, I used Merge node to simulate how a Gmail node would behave when it receives an email with attachments. Here’s how it works:

  1. Simulated Gmail Output Using a Merge Node
    In your setup, the Merge node is acting like the Gmail node, and it’s outputting 2 items. These represent two file attachments, for example:

    • attachment_0
    • attachment_1
  2. Passing Attachments to Google Drive
    These two attachments are passed as inputs to the Google Drive node. Since there are two items, the Google Drive node will run once for each item.

  3. What Happens in the Google Drive Node
    For each input (i.e., each simulated attachment), the Google Drive node:

    • Automatically picks up the binary file data using {{$binary.keys()[0]}}.
    • Automatically detects the filename using {{$binary.attachment_0.fileName}}.
    • Uploads each file individually to your Drive.

Hope it helps! :slight_smile:

Happy flowgramming :sunflower:

-Sudhanshu

1 Like

Wow that fixed it! I had tried {{ $binary }} which returned the entire array, but I guess I didn’t consider using .keys. Very nice! Thanks so much!

BTW… cool how you dropped that flow in there. annd… as I’m asking how you did that, I see the tip above the chatbox to click the ‘</>’ then paste your workflow. Now I see why mine got munged earlier haha…

Anyway, cheers mate thanks alot!

1 Like

Glad it worked out! :smile: Yep, that </> tip helps keep things tidy…easy to miss at first. Anytime, happy to help.

Please mark it as solution.

Cheers!

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