Self-hosted n8n? Berücksichtigen Sie eine der folgenden Optionen zum Hochladen auf Notion!

Anfänger

Dies ist ein File Management-Bereich Automatisierungsworkflow mit 5 Nodes. Hauptsächlich werden Code, Compression, HttpRequest, ManualTrigger und andere Nodes verwendet. Konvertieren Sie mehrere Dateien mithilfe von JavaScript-Code in Base64

Voraussetzungen
  • Möglicherweise sind Ziel-API-Anmeldedaten erforderlich
Workflow-Vorschau
Visualisierung der Node-Verbindungen, mit Zoom und Pan
Workflow exportieren
Kopieren Sie die folgende JSON-Konfiguration und importieren Sie sie in n8n
{
  "id": "p7W4ZMpMtfFP7HYK",
  "meta": {
    "instanceId": "8981479cb588889c05b145eaed421551d37a4fff11ab279d3f4744a6577c6002"
  },
  "name": "Base64 Encode Multiple Binary Files with a Code Node",
  "tags": [],
  "nodes": [
    {
      "id": "d5da9ec6-6637-4ffb-ae95-a6a0136ff0bb",
      "name": "Bei Klick auf 'Workflow ausführen'",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        0,
        272
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "254e27aa-3538-428b-99e2-2925e366bf74",
      "name": "Demo-Website-Zip n8n herunterladen",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        208,
        272
      ],
      "parameters": {
        "url": "https://github.com/n8n-io/n8n-demo-website/archive/refs/heads/main.zip",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "31f153cd-7689-4477-aa54-a5c19820f77e",
      "name": "Entpacken",
      "type": "n8n-nodes-base.compression",
      "position": [
        416,
        272
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "40d696a3-024d-46fb-bf42-2a1262148eca",
      "name": "In Base64 kodieren",
      "type": "n8n-nodes-base.code",
      "position": [
        624,
        272
      ],
      "parameters": {
        "jsCode": "/**\n * Encodes multiple binary files from an n8n input item into Base64 strings.\n *\n * This code assumes it is running in an n8n \"Code\" or \"Function\" node\n * where 'this' refers to the node's context and 'helpers' are available.\n *\n * @returns {object} An object containing an array of file objects,\n * each with a 'path' and 'data' (Base64 string).\n */\nconst results = [];\n\n// The 'async' keyword is required for the outer function to use 'await'.\n// It is assumed the surrounding function is already declared as 'async'.\nfor (const file in $input.first().binary) {\n  try {\n    // Retrieve the binary object for the current file key.\n    const bin = $input.first().binary[file];\n\n    // Use n8n's helper function to get the file buffer.\n    const binBuffer = await this.helpers.getBinaryDataBuffer(0, file);\n\n    // Construct the file path, handling cases with or without a directory.\n    const path = bin.directory\n      ? `${bin.directory}/${bin.fileName}`\n      : bin.fileName;\n\n    // Push a new object to the results array.\n    results.push({\n      path: path,\n      data: Buffer.from(binBuffer).toString('base64'),\n    });\n  } catch (error) {\n    // Log any errors that occur during processing.\n    console.error(`Error processing file \"${file}\": ${error.message}`);\n    // You could also choose to throw the error or handle it differently here.\n  }\n}\n\n// Return the final object in the expected format for the next node.\nreturn { files: results };\n"
      },
      "typeVersion": 2
    },
    {
      "id": "639311dd-9ae7-42c7-aa33-cfdedf9922a8",
      "name": "Haftnotiz",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        -160
      ],
      "parameters": {
        "width": 720,
        "height": 384,
        "content": "## Base64 Encode Multiple Binary Files with a Code Node\nThis template demonstrates how to handle multiple binary files in n8n by using a Code node to convert them into a Base64 encoded string. It's particularly useful when an API requires file uploads in this format and the standard 'Extract From File' node is not sufficient for batch processing. The workflow starts by downloading a ZIP file, unzipping it to get multiple binary files, and then uses a Code node with custom JavaScript to encode each file individually.\n### Instructions\n1. Download and import this template into your n8n instance.\n2. Run the workflow once to see how it downloads, unzips, and then encodes multiple files.\n3. Modify the 'HTTP Request' node to download your own binary file or a ZIP file containing multiple files.\n4. Update the 'Code' node if you need to adjust the output format or file paths.\n5. Use the output of the 'Code' node in a subsequent node, such as another 'HTTP Request' to send the Base64-encoded files to your desired API.\n\nA link to the full blog post is available [here](https://n8n-tips.blogspot.com/2025/08/from-binary-to-base64-guide-to-file.html)"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "785dadc6-7b0e-4baf-888f-5dd068d4689d",
  "connections": {
    "31f153cd-7689-4477-aa54-a5c19820f77e": {
      "main": [
        [
          {
            "node": "40d696a3-024d-46fb-bf42-2a1262148eca",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "254e27aa-3538-428b-99e2-2925e366bf74": {
      "main": [
        [
          {
            "node": "31f153cd-7689-4477-aa54-a5c19820f77e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d5da9ec6-6637-4ffb-ae95-a6a0136ff0bb": {
      "main": [
        [
          {
            "node": "254e27aa-3538-428b-99e2-2925e366bf74",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Häufig gestellte Fragen

Wie verwende ich diesen Workflow?

Kopieren Sie den obigen JSON-Code, erstellen Sie einen neuen Workflow in Ihrer n8n-Instanz und wählen Sie "Aus JSON importieren". Fügen Sie die Konfiguration ein und passen Sie die Anmeldedaten nach Bedarf an.

Für welche Szenarien ist dieser Workflow geeignet?

Anfänger - Dateiverwaltung

Ist es kostenpflichtig?

Dieser Workflow ist völlig kostenlos. Beachten Sie jedoch, dass Drittanbieterdienste (wie OpenAI API), die im Workflow verwendet werden, möglicherweise kostenpflichtig sind.

Workflow-Informationen
Schwierigkeitsgrad
Anfänger
Anzahl der Nodes5
Kategorie1
Node-Typen5
Schwierigkeitsbeschreibung

Für n8n-Anfänger, einfache Workflows mit 1-5 Nodes

Externe Links
Auf n8n.io ansehen

Diesen Workflow teilen

Kategorien

Kategorien: 34