¿Autohospedar n8n? ¡Considere usar una de estas opciones para subir a Notion!
Este es unFile Managementflujo de automatización del dominio deautomatización que contiene 5 nodos.Utiliza principalmente nodos como Code, Compression, HttpRequest, ManualTrigger. Convertir múltiples archivos a Base64 mediante código JavaScript
- •Pueden requerirse credenciales de autenticación para la API de destino
Nodos utilizados (5)
Categoría
{
"id": "p7W4ZMpMtfFP7HYK",
"meta": {
"instanceId": "8981479cb588889c05b145eaed421551d37a4fff11ab279d3f4744a6577c6002"
},
"name": "Base64 Encode Multiple Binary Files with a Code Node",
"tags": [],
"nodes": [
{
"id": "d5da9ec6-6637-4ffb-ae95-a6a0136ff0bb",
"name": "Al hacer clic en 'Ejecutar flujo de trabajo'",
"type": "n8n-nodes-base.manualTrigger",
"position": [
0,
272
],
"parameters": {},
"typeVersion": 1
},
{
"id": "254e27aa-3538-428b-99e2-2925e366bf74",
"name": "Descargar el zip del sitio web demo n8n",
"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": "Descomprimir",
"type": "n8n-nodes-base.compression",
"position": [
416,
272
],
"parameters": {},
"typeVersion": 1.1
},
{
"id": "40d696a3-024d-46fb-bf42-2a1262148eca",
"name": "Codificar a base64",
"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": "Nota adhesiva",
"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
}
]
]
}
}
}¿Cómo usar este flujo de trabajo?
Copie el código de configuración JSON de arriba, cree un nuevo flujo de trabajo en su instancia de n8n y seleccione "Importar desde JSON", pegue la configuración y luego modifique la configuración de credenciales según sea necesario.
¿En qué escenarios es adecuado este flujo de trabajo?
Principiante - Gestión de archivos
¿Es de pago?
Este flujo de trabajo es completamente gratuito, puede importarlo y usarlo directamente. Sin embargo, tenga en cuenta que los servicios de terceros utilizados en el flujo de trabajo (como la API de OpenAI) pueden requerir un pago por su cuenta.
Flujos de trabajo relacionados recomendados
Viktor Klepikovskyi
@vklepikovskyiCompartir este flujo de trabajo