Terug naar sjablonen
WORKFLOWSJABLOON
Re Access Binary Data From Previous Node | Operasyon için n8n Otomasyon İş Akışı Şablonu (HTTP)
n8n için hazır otomasyon şablonu: Re Access Binary Data From Previous Node. 4 düğüm. Entegrasyonlar: HTTP. JSON'u kopyalayıp n8n'e içe aktarın.
4 nodesRe_Access_Binary_Data_From_Previous_Node-workflow.json
{"meta": {"creator": "Lucas Peyrin","instanceId": "e409ea34548a2afe2dffba31130cd1cf2e98ebe2afaeed2a63caf2a0582d1da0","fingerprint": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjcmVhdG9yIjoiIiwiaXNzIjoibjhuIiwiaWF0IjoxNzU4MzgyMTA3fQ.adMD662XvlKrH8GK9_H5LZlSpvrhUUTpD8AdPGY5Rok"},"nodes": [{"id": "acbfe599-0e66-43f8-acf8-92f3d863f963","cid": "Ikx1Y2FzIFBleXJpbiI","name": "Re-Access Binary Data from Previous Node","type": "n8n-nodes-base.code","notes": "© 2025 Lucas Peyrin","creator": "Lucas Peyrin","position": [704,96],"parameters": {"jsCode": "// IMPORTANT: Change this to the name of the node you want to get binary files from.\nconst previousNodeName = 'Get n8n Logo (Binary)';\n\n// This will hold all the items we process.\nconst allItems = [];\n\n// Loop over every item that is coming into this Code node.\nfor (const item of $input.all()) {\n\n // For the current item in the loop, find its corresponding item from the previous node.\n // The '.item' accessor automatically links the current item to its parent from the specified node.\n const previousNodeItem = $(previousNodeName).item;\n\n // Check if the corresponding item from the previous node actually has binary data.\n if (previousNodeItem && previousNodeItem.binary) {\n\n // Ensure the current item has a 'binary' object to add files to.\n // This also prevents overwriting any binary data the current item might already have.\n item.binary = item.binary || {};\n\n // Now, loop over ALL keys (each key represents a file) in the binary object.\n for (const inputPropertyName in previousNodeItem.binary) {\n \n // Get the specific binary file's data (which includes the base64 data and fileName).\n const binary = previousNodeItem.binary[inputPropertyName];\n\n // Decode the base64 data into a Buffer.\n const myBuffer = Buffer.from(binary.data, 'base64');\n\n // Use the n8n helper to prepare the binary data correctly for the next node\n // and attach it to the current item's binary object using its original property name.\n item.binary[inputPropertyName] = await this.helpers.prepareBinaryData(myBuffer, binary.fileName);\n }\n }\n\n // Add the processed item (with its new binary data) to our results array.\n allItems.push(item);\n}\n\n// Return all the processed items.\nreturn allItems;"},"typeVersion": 2},{"id": "8a68bb24-ee5a-44f6-bfc2-0beafe04e099","cid": "Ikx1Y2FzIFBleXJpbiI","name": "Remove Binary Data","type": "n8n-nodes-base.set","notes": "© 2025 Lucas Peyrin","creator": "Lucas Peyrin","position": [304,96],"parameters": {"options": {},"assignments": {"assignments": [{"id": "66ff2460-78b7-4231-b6ef-108acb51cd23","name": "new_field","type": "string","value": "test value"}]}},"typeVersion": 3.4,"alwaysOutputData": false},{"id": "17dc22f1-d81f-4511-a9b6-85f33d95ddbb","cid": "Ikx1Y2FzIFBleXJpbiI","name": "Get n8n Logo (Binary)","type": "n8n-nodes-base.httpRequest","notes": "© 2025 Lucas Peyrin","creator": "Lucas Peyrin","position": [-32,96],"parameters": {"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/5/53/N8n-logo-new.svg/2560px-N8n-logo-new.svg.png","options": {}},"typeVersion": 4.2},{"id": "d1cd2a15-5ce1-4437-a123-d993550054c3","cid": "Ikx1Y2FzIFBleXJpbiI","name": "Start","type": "n8n-nodes-base.manualTrigger","notes": "© 2025 Lucas Peyrin","creator": "Lucas Peyrin","position": [-320,96],"parameters": {},"typeVersion": 1},{"id": "0df6b57c-c9e3-4bfc-a3a9-52403b6cd0d9","cid": "Ikx1Y2FzIFBleXJpbiI","name": "Sticky Note (0)","type": "n8n-nodes-base.stickyNote","notes": "© 2025 Lucas Peyrin","creator": "Lucas Peyrin","position": [-592,-400],"parameters": {"color": "0","width": 448,"height": 544,"content": "## Re-Access Binary Data\n\nThis workflow demonstrates a powerful technique: **how to re-access binary data from any previous node in your workflow, even if an intermediate node removes it.**\n\nThis is crucial when you need to process binary files (like images, PDFs) across multiple steps, especially if a node in between doesn't preserve binary data by default.\n\n\n### To get started:\n1. Click **Run Workflow**.\n2. Observe the output of the `Re-Access Binary Data from Previous Node` to see the binary data re-attached.\n\n\n### Questions or Feedback?\nFor feedback, coaching, built-for-you workflows, or any questions, use my unified AI-powered contact form.\n\n➡️ **[Get in Touch Here](https://api.ia2s.app/form/templates/academy)**\n\n*Happy Automating! —Lucas Peyrin*"},"typeVersion": 1},{"id": "e3e5944b-f2dd-4411-bd83-ab7755d95962","cid": "Ikx1Y2FzIFBleXJpbiI","name": "Sticky Note (1)","type": "n8n-nodes-base.stickyNote","notes": "© 2025 Lucas Peyrin","creator": "Lucas Peyrin","position": [-112,-48],"parameters": {"color": "7","width": 256,"height": 192,"content": "This node fetches a binary image (the n8n logo) from a URL.\n\nIt's the source of the binary data we'll be working with.\n\n\n\n\n\n\n\n\n\n\n\n"},"typeVersion": 1},{"id": "ded5a9bd-a23e-4022-be31-905e30bef576","cid": "Ikx1Y2FzIFBleXJpbiI","name": "Sticky Note (2)","type": "n8n-nodes-base.stickyNote","notes": "© 2025 Lucas Peyrin","creator": "Lucas Peyrin","position": [176,-128],"parameters": {"color": 7,"width": 352,"height": 272,"content": "⚠️ **Important Concept!**\n\nBy default, many n8n nodes (like the `Set` node in this case) **do not pass binary data** to subsequent nodes.\n\nThis node simulates a common scenario where binary data is \"lost\" in the flow, which the next `Code` node will address.\n\n\n\n\n\n\n\n\n\n"},"typeVersion": 1},{"id": "da33a06c-e9a6-4945-bef7-4d0852ca78ef","cid": "Ikx1Y2FzIFBleXJpbiI","name": "Sticky Note (3)","type": "n8n-nodes-base.stickyNote","notes": "© 2025 Lucas Peyrin","creator": "Lucas Peyrin","position": [560,-320],"parameters": {"color": "6","width": 400,"height": 464,"content": "### The Magic Happens Here!\n\nThis `Code` node demonstrates how to **re-access binary data** from *any* previous node in the workflow, even if it was dropped by an intermediate node.\n\nIt uses:\n* `$(previousNodeName).item`: To get the full item from the specified previous node.\n* `this.helpers.prepareBinaryData()`: To correctly re-attach the binary data to the current item.\n\n---\n\n💡 **Customize:**\nIf you adapt this to your workflow, remember to update the `previousNodeName` variable in the code to match the name of the node that originally produced the binary data you want to retrieve.\n\n\n\n\n\n\n\n\n\n"},"typeVersion": 1}],"pinData": {},"connections": {"Start": {"main": [[{"node": "Get n8n Logo (Binary)","type": "main","index": 0}]]},"Remove Binary Data": {"main": [[{"node": "Re-Access Binary Data from Previous Node","type": "main","index": 0}]]},"Get n8n Logo (Binary)": {"main": [[{"node": "Remove Binary Data","type": "main","index": 0}]]}}}
In n8n Editor: plakken met Ctrl+V→Workflow wordt aangemaakt