Google Drive文件加载器
中级
这是一个Building Blocks领域的自动化工作流,包含 8 个节点。主要使用 Set, Code, GoogleDocs, GoogleDrive, ExecuteWorkflowTrigger 等节点。 从Google Drive文件夹加载并聚合文件到键值字典
前置要求
- •Google Drive API 凭证
分类
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"name": "Google Drive文件加载器",
"nodes": [
{
"id": "3d066626-a87d-4e7b-bc16-9f47e1277dde",
"name": "当由另一个工作流执行时",
"type": "n8n-nodes-base.executeWorkflowTrigger",
"position": [
0,
0
],
"parameters": {
"inputSource": "jsonExample",
"jsonExample": "{\n}"
},
"typeVersion": 1.1
},
{
"id": "cb0e5563-1550-4121-9fd5-b1cbd9810476",
"name": "代码",
"type": "n8n-nodes-base.code",
"position": [
960,
0
],
"parameters": {
"jsCode": "// n8n Code Node\n\n// Initialize an empty object to store the aggregated results\nconst aggregatedDict = {};\n\n// Get all input items passed to this node\nconst inputItems = $input.all();\n\n// Loop through each input item\nfor (const item of inputItems) {\n // Get the JSON data from the current item\n const itemJson = item.json;\n\n // Check if item.json is actually an object and not null/undefined\n // Also ensure it's not an array, as we expect key-value pairs\n if (itemJson && typeof itemJson === 'object' && !Array.isArray(itemJson)) {\n\n // Iterate over all the keys within the current item's JSON object\n for (const key of Object.keys(itemJson)) {\n // Add/overwrite the key-value pair to our aggregated dictionary\n aggregatedDict[key] = itemJson[key].replaceAll(/\\n+/g, \"\\n\");\n // console.log(`Adding/Updating key: ${key}`); // Optional: for debugging\n }\n\n } else {\n // Optional: Log a warning if an item doesn't have the expected format\n console.warn(`Skipping item - 'json' property is not a valid object:`, itemJson);\n }\n}\n\n// n8n expects an array of items as output.\n// We return a single item containing the final aggregated dictionary in its 'json' property.\nreturn [{ json: aggregatedDict }];"
},
"typeVersion": 2
},
{
"id": "1b90ca95-7251-4573-9b0b-4af3622721ba",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
140,
-140
],
"parameters": {
"height": 300,
"content": "## 步骤1"
},
"typeVersion": 1
},
{
"id": "d26c2f27-0095-4dd6-9aa5-94c68f58bda3",
"name": "从文件夹获取文件",
"type": "n8n-nodes-base.googleDrive",
"position": [
220,
0
],
"parameters": {
"filter": {
"folderId": {
"mode": "list",
"value": "root",
"cachedResultName": "/ (Root folder)"
}
},
"options": {},
"resource": "fileFolder"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "Ng83G9mU8KtY3wu6",
"name": "Google Drive account"
}
},
"typeVersion": 3
},
{
"id": "938c8f7c-84b1-4eeb-a7c8-894ae5fbc275",
"name": "下载Google文档",
"type": "n8n-nodes-base.googleDocs",
"position": [
500,
0
],
"parameters": {
"operation": "get",
"documentURL": "={{ $json.id }}"
},
"credentials": {
"googleDocsOAuth2Api": {
"id": "bbAywBJpCuYeRX89",
"name": "Google Docs account"
}
},
"typeVersion": 2
},
{
"id": "caa075a2-2e85-47e5-a829-425a1177e5be",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
420,
-140
],
"parameters": {
"height": 300,
"content": "## 步骤2"
},
"typeVersion": 1
},
{
"id": "05db5439-584e-40aa-9c1d-101618f66fdc",
"name": "映射",
"type": "n8n-nodes-base.set",
"position": [
780,
0
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "b33e9355-659a-4b71-ba5c-00c90b7ed792",
"name": "={{ $('Get files from folder').item.json.name }}",
"type": "string",
"value": "={{ $json.content }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "85dc7e65-7d50-4b13-b114-88b4020865e8",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
720,
-140
],
"parameters": {
"color": 3,
"width": 400,
"height": 300,
"content": "## 映射"
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"Mapping": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
},
"Download Google Docs": {
"main": [
[
{
"node": "Mapping",
"type": "main",
"index": 0
}
]
]
},
"Get files from folder": {
"main": [
[
{
"node": "Download Google Docs",
"type": "main",
"index": 0
}
]
]
},
"When Executed by Another Workflow": {
"main": [
[
{
"node": "Get files from folder",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 构建模块
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
使用Redis防止工作流并发运行
使用Redis防止工作流并发运行
If
Set
Wait
+8
43 节点Hugues Stock
工程
✨🩷自动化社交媒体内容发布工厂 + 系统提示组合
基于动态系统提示和GPT-4o的AI驱动多平台社交媒体内容工厂
If
Set
Code
+20
100 节点Amit Mehta
内容创作
WordPress博客自动化专业版(深度研究)v2.1市场
使用GPT-4o、Perplexity AI和多语言支持自动化SEO优化的博客创建
If
Set
Xml
+27
125 节点Daniel Ng
内容创作
✨🩷自动化社交媒体内容发布工厂 + 系统提示组合
使用GPT-4o为6个平台生成平台优化的社交媒体内容
If
Set
Code
+20
100 节点Luan Correia
社交媒体
(Duc)深度研究市场模板
集成PerplexityAI研究和OpenAI内容的多层级WordPress博客生成器
If
Set
Xml
+28
132 节点Daniel Ng
人工智能
WordPress博客自动化专业版(深度研究)v1
WordPress自动博客专业版 - 含深度研究的内容自动化机器
If
Set
Xml
+24
77 节点Daniel Ng
人工智能