8
n8n 中文网amn8n.com

将图片从Google Drive自动传输到Google Docs并调整大小

中级

这是一个Document Extraction, Multimodal AI领域的自动化工作流,包含 15 个节点。主要使用 Code, Wait, GoogleDrive, HttpRequest, ManualTrigger 等节点。 Google Drive和Google Docs模板,结构清晰,目的明确

前置要求
  • Google Drive API 凭证
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "Hbn25OnndpfNGOuu",
  "meta": {
    "instanceId": "5f1d044fa23a5710e3ad8c8ced8193dff576e0e1920d0390510f41e9622a2d1c",
    "templateCredsSetupCompleted": true
  },
  "name": "将图片从Google Drive自动传输到Google Docs并调整大小",
  "tags": [],
  "nodes": [
    {
      "id": "d3e3e121-15b9-4a85-bebe-0915116bf310",
      "name": "当点击“执行工作流”时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -940,
        -140
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "bf6a7390-7fb0-4df3-bc15-04b5842f5d9e",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -180,
        220
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "0e92fa37-e4b6-4fe8-b394-bb8f7f3fc6a2",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1000,
        100
      ],
      "parameters": {
        "color": 6,
        "width": 700,
        "height": 320,
        "content": "## 筛选URI和图片尺寸"
      },
      "typeVersion": 1
    },
    {
      "id": "7a3911db-e786-4f12-bf8d-ff27be32407f",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        100
      ],
      "parameters": {
        "color": 4,
        "width": 460,
        "height": 320,
        "content": "## 发送图片到Docs"
      },
      "typeVersion": 1
    },
    {
      "id": "d056ab42-1891-4574-8383-4ca6306249de",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1000,
        -240
      ],
      "parameters": {
        "width": 1220,
        "height": 280,
        "content": "## 触发并从Google Drive下载图片"
      },
      "typeVersion": 1
    },
    {
      "id": "6504dc49-1732-418d-a187-722b767699ce",
      "name": "下载文件",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -300,
        -140
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {
          "fileName": "={{ $json.name }}"
        },
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "pWdhkGnBAsbN68dw",
          "name": "garrynacov"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "e33f5b2e-fc15-4500-90e7-22cc5207aec2",
      "name": "筛选URI",
      "type": "n8n-nodes-base.code",
      "position": [
        -920,
        220
      ],
      "parameters": {
        "jsCode": "return items\n  .sort((a, b) => {\n    const getNumber = name => parseInt(name?.json?.name?.match(/\\d+/)?.[0] || 0, 10);\n    return getNumber(b) - getNumber(a); // Descending\n  })\n  .map(item => {\n    const imageId = item.json.id;\n    return {\n      json: {\n        uri: `https://drive.google.com/uc?export=view&id=${imageId}`\n      }\n    };\n  });\n"
      },
      "typeVersion": 2
    },
    {
      "id": "9add85c8-dd91-4cbb-b324-4471f4839ca8",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1380,
        -240
      ],
      "parameters": {
        "width": 340,
        "height": 280,
        "content": "**工作原理**"
      },
      "typeVersion": 1
    },
    {
      "id": "ff79d864-25db-40eb-9b65-2fe4a45b989d",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1380,
        100
      ],
      "parameters": {
        "color": 5,
        "width": 340,
        "height": 580,
        "content": "**设置步骤**"
      },
      "typeVersion": 1
    },
    {
      "id": "b87b0631-9508-4653-97fc-70ba845de464",
      "name": "在Google Drive中搜索文件",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -720,
        -140
      ],
      "parameters": {
        "filter": {
          "folderId": {
            "__rl": true,
            "mode": "list",
            "value": "1bMnN5da0iMxMPv1IgSlsRvXgdt5PGq84",
            "cachedResultUrl": "https://drive.google.com/drive/folders/1bMnN5da0iMxMPv1IgSlsRvXgdt5PGq84",
            "cachedResultName": "19 MEI 2025"
          }
        },
        "options": {},
        "resource": "fileFolder",
        "returnAll": true
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "pWdhkGnBAsbN68dw",
          "name": "garrynacov"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "447148b6-2a71-44e5-9c8c-a08d035ea2af",
      "name": "调整图片大小",
      "type": "n8n-nodes-base.code",
      "position": [
        -500,
        220
      ],
      "parameters": {
        "jsCode": "return items.map((item, index) => {\n  const name = item.json.name || \"\"; // fallback jika tidak ada\n  const isThumbnail = name.includes(\"thumb\");\n\n  const width = isThumbnail ? 200 : 400;\n  const height = isThumbnail ? 150 : 250;\n\n  return {\n    json: {\n      requests: [{\n        insertInlineImage: {\n          uri: item.json.uri,\n          location: {\n            index: 1\n          },\n          objectSize: {\n            height: { magnitude: height, unit: 'PT' },\n            width: { magnitude: width, unit: 'PT' }\n          }\n        }\n      }]\n    }\n  }\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "bdd774c5-4c00-4865-9356-539c3f8f18d4",
      "name": "插入图片到Google文档",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        40,
        240
      ],
      "parameters": {
        "url": "https://docs.googleapis.com/v1/documents/1IkozrnIqirwn4mwbHdMl25f013P59Nvd-Fw8kg_Eyw4:batchUpdate",
        "method": "POST",
        "options": {
          "timeout": 10000,
          "response": {
            "response": {
              "fullResponse": true,
              "responseFormat": "text",
              "outputPropertyName": "={{ $json.requests[0].insertInlineImage.uri }}"
            }
          }
        },
        "sendBody": true,
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "requests",
              "value": "={{ $json.requests }}"
            }
          ]
        },
        "nodeCredentialType": "googleDocsOAuth2Api"
      },
      "credentials": {
        "googleDocsOAuth2Api": {
          "id": "SsGr3Mdm1aSmDbCN",
          "name": "Google Docs account"
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.2
    },
    {
      "id": "f08e9f64-f715-4d55-956b-f94e3f6cb8b1",
      "name": "批处理等待计时器-1",
      "type": "n8n-nodes-base.wait",
      "position": [
        -500,
        -140
      ],
      "webhookId": "7acd09d7-1eba-48d5-95c4-4ded59ddee9d",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "4e90733e-9d50-4119-a256-28422ad4c324",
      "name": "批处理等待计时器-2",
      "type": "n8n-nodes-base.wait",
      "position": [
        -80,
        -140
      ],
      "webhookId": "87c3d9dd-7569-4b92-aa47-223271241a94",
      "parameters": {
        "amount": 3
      },
      "typeVersion": 1.1
    },
    {
      "id": "c5f057c2-adf2-4c9d-8b35-ed79fec70a15",
      "name": "批处理等待计时器-3",
      "type": "n8n-nodes-base.wait",
      "position": [
        -720,
        220
      ],
      "webhookId": "87c3d9dd-7569-4b92-aa47-223271241a94",
      "parameters": {
        "amount": 3
      },
      "typeVersion": 1.1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "2d5fcbc0-db8f-45b7-8cc6-66ae54a4f06d",
  "connections": {
    "Resize Image": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download File": {
      "main": [
        [
          {
            "node": "Batch Wait Timer-2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filtering URI": {
      "main": [
        [
          {
            "node": "Batch Wait Timer-3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Insert Image to Google Doc",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Batch Wait Timer-1": {
      "main": [
        [
          {
            "node": "Download File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Batch Wait Timer-2": {
      "main": [
        [
          {
            "node": "Filtering URI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Batch Wait Timer-3": {
      "main": [
        [
          {
            "node": "Resize Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert Image to Google Doc": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search File in Google Drive": {
      "main": [
        [
          {
            "node": "Batch Wait Timer-1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Search File in Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 文档提取, 多模态 AI

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量15
分类2
节点类型7
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Garri

Garri

@garri

Security Analyst with expertise in penetration testing, threat detection, and AI-driven automation. Experienced in securing systems, identifying vulnerabilities, and building proactive security solutions. Focused on leveraging technological innovation to create safe and efficient digital environments.

外部链接
在 n8n.io 查看

分享此工作流