{
  "nodes": [
    {
      "id": "acbfe599-0e66-43f8-acf8-92f3d863f963",
      "name": "Re-Access Binary Data from Previous Node",
      "type": "n8n-nodes-base.code",
      "notes": "\u00a9 2025 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",
      "name": "Remove Binary Data",
      "type": "n8n-nodes-base.set",
      "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",
      "name": "Get n8n Logo (Binary)",
      "type": "n8n-nodes-base.httpRequest",
      "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",
      "name": "Start",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -320,
        96
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "e3e5944b-f2dd-4411-bd83-ab7755d95962",
      "name": "Sticky Note (1)",
      "type": "n8n-nodes-base.stickyNote",
      "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",
      "name": "Sticky Note (2)",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        176,
        -128
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 272,
        "content": "\u26a0\ufe0f **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",
      "name": "Sticky Note (3)",
      "type": "n8n-nodes-base.stickyNote",
      "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\ud83d\udca1 **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
    },
    {
      "id": "9085f0c7-28f9-4156-8e64-19d4556a4f13",
      "name": "Sticky Note (0)",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -592,
        -464
      ],
      "parameters": {
        "color": 0,
        "width": 448,
        "height": 608,
        "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---\n\n### Automate your operations today\nYour time is valuable. Let us automate the boring stuff for you.\n\n**\ud83d\udc47 CHOOSE YOUR PATH:**\n\n[ **\u26a1\ufe0f I WANT A FREE AUDIT (2 min)** ](https://workflows.ac/audit?utm_source=n8n_template&utm_medium=workflow_note&utm_campaign=re_access_binary_data_from_any_previous_node&utm_content=8780)\n> *We've put our heart into this business evaluation machine.*\n\n[ **\ud83d\udca1 I HAVE A SPECIFIC REQUEST** ](https://workflows.ac/form?utm_source=n8n_template&utm_medium=workflow_note&utm_campaign=re_access_binary_data_from_any_previous_node&utm_content=8780)\n"
      },
      "typeVersion": 1
    },
    {
      "id": "a5b9c4fe-fffc-4d48-8050-c0ce15eb6fe6",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1008,
        -912
      ],
      "parameters": {
        "color": 7,
        "width": 384,
        "height": 1056,
        "content": "---\n\n## Was this helpful? Let me know!\n[![clic](https://supastudio.ia2s.app/storage/v1/object/public/assets/n8n/clic_down_lucas.gif)](https://api.ia2s.app/form/templates/academy)\n\nI really hope this template helped you. Your feedback is what helps me create better resources for the n8n community.\n\n### **Have Feedback, a Question, or a Project Idea?**\n\n\n#### \u27a1\ufe0f **[Click here to go to the Contact Form](https://workflows.ac/form?utm_source=n8n_template&utm_medium=workflow_note&utm_campaign=re_access_binary_data_from_any_previous_node&utm_content=8780)**\n\nUse this single link for anything you need:\n\n*   **Give Feedback:** Share your thoughts on this template, whether you found a typo, encountered an unexpected error, have a suggestion, or just want to say thanks!\n\n*   **Automation Coaching:** Get personalized, one-on-one guidance to master n8n. We can work together to help you reach an expert level.\n\n*   **Automation Consulting:** Have a complex business challenge or need custom workflows built from scratch? We offer a plug and play automation department for 8 to 88 people teams with unlimited automation requests.\n\n---\n\nHappy Automating!\nLucas Peyrin | [Workflows Accelerator](https://workflows.ac?utm_source=n8n_template&utm_medium=workflow_note&utm_campaign=re_access_binary_data_from_any_previous_node&utm_content=8780)"
      },
      "typeVersion": 1
    }
  ],
  "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
          }
        ]
      ]
    }
  }
}