自托管n8n?考虑使用以下选项之一上传到Notion!
初级
这是一个File Management领域的自动化工作流,包含 5 个节点。主要使用 Code, Compression, HttpRequest, ManualTrigger 等节点。 使用JavaScript代码将多个文件转换为Base64
前置要求
- •可能需要目标 API 的认证凭证
分类
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "p7W4ZMpMtfFP7HYK",
"meta": {
"instanceId": "8981479cb588889c05b145eaed421551d37a4fff11ab279d3f4744a6577c6002"
},
"name": "### 自托管n8n?考虑使用以下选项之一上传到Notion!",
"tags": [],
"nodes": [
{
"id": "d5da9ec6-6637-4ffb-ae95-a6a0136ff0bb",
"name": "当点击“执行工作流”时",
"type": "n8n-nodes-base.manualTrigger",
"position": [
0,
272
],
"parameters": {},
"typeVersion": 1
},
{
"id": "254e27aa-3538-428b-99e2-2925e366bf74",
"name": "使用代码节点对多个二进制文件进行Base64编码",
"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": "下载n8n演示网站zip",
"type": "n8n-nodes-base.compression",
"position": [
416,
272
],
"parameters": {},
"typeVersion": 1.1
},
{
"id": "40d696a3-024d-46fb-bf42-2a1262148eca",
"name": "解压缩",
"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": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
0,
-160
],
"parameters": {
"width": 720,
"height": 384,
"content": "编码为base64"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "785dadc6-7b0e-4baf-888f-5dd068d4689d",
"connections": {
"Unzip": {
"main": [
[
{
"node": "Encode to base64",
"type": "main",
"index": 0
}
]
]
},
"Download n8n demo website zip": {
"main": [
[
{
"node": "Unzip",
"type": "main",
"index": 0
}
]
]
},
"When clicking ‘Execute workflow’": {
"main": [
[
{
"node": "Download n8n demo website zip",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
初级 - 文件管理
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
无代码:将多个二进制文件转换为Base64
无需自定义代码将多个二进制文件转换为Base64 JSON数组
Set
Split Out
Aggregate
+5
8 节点Viktor Klepikovskyi
JSON文件夹分离
从Google表格批量下载JSON文件到本地文件夹
Code
Http Request
Google Sheets
+4
16 节点Rahul Joshi
文件管理
使用子工作流的嵌套循环
使用n8n子工作流创建嵌套数据处理循环
Set
Code
Manual Trigger
+4
9 节点Viktor Klepikovskyi
工程
使用Google Drive推送通知监控文件变更
通过Google Drive推送通知监控文件变更
If
Set
Code
+10
29 节点Jimleuk
文件管理
n8n异步工作流与Wait节点概念验证
使用异步处理和Webhook并行运行多个任务
Wait
Merge
Summarize
+5
12 节点Viktor Klepikovskyi
杂项
提示 #3:重试/延迟超过 5 秒/5 次尝试
提示 #3:重试/延迟超过 5 秒/5 次尝试
If
Set
Wait
+4
8 节点Viktor Klepikovskyi
工程