8
n8n 中文网amn8n.com

初学者教程:使用n8n管理Google Cloud Storage存储桶和对象

高级

这是一个File Management, Multimodal AI领域的自动化工作流,包含 18 个节点。主要使用 Set, ManualTrigger, Agent, OpenAi, GoogleCloudStorage 等节点。 使用GPT-4 Mini AI图像生成管理Google Cloud Storage

前置要求
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "nSlsWDi56czfBf3u",
  "meta": {
    "instanceId": "4a2e6764ba7a6bc9890d9225f4b21d570ce88fc9bd57549c89057fcee58fed0f",
    "templateCredsSetupCompleted": true
  },
  "name": "初学者教程:使用 n8n 管理 Google Cloud Storage 存储桶和对象",
  "tags": [
    {
      "id": "NacOgNreMya1Dsve",
      "name": "google cloud",
      "createdAt": "2025-08-17T07:30:47.533Z",
      "updatedAt": "2025-08-17T07:30:47.533Z"
    }
  ],
  "nodes": [
    {
      "id": "45a84f10-bd83-4896-8419-1e7ef93377c5",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        448,
        248
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "PPSwAKeLQYgAPobT",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "9ba48335-7513-4c59-a727-c2bdb45241aa",
      "name": "生成图片",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        752,
        24
      ],
      "parameters": {
        "prompt": "={{ $json.output }}",
        "options": {},
        "resource": "image"
      },
      "credentials": {
        "openAiApi": {
          "id": "PPSwAKeLQYgAPobT",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "bb4afa1e-8c09-402c-bc36-ba6f4f973a48",
      "name": "提示生成智能体",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        352,
        24
      ],
      "parameters": {
        "text": "=You're prompt generator agent, you will create prompt for the open-ai image generation model with a random topic among:\n- Education\n- Science \n- Sport\n- Economy\n- Health\nOutput the prompt only, nothing else",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2.1
    },
    {
      "id": "127f18fb-aba1-4524-9ffe-874571d0e1cc",
      "name": "点击\"执行工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -320,
        -124
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "b985d495-9156-4b5b-9042-163c13095bd0",
      "name": "编辑字段",
      "type": "n8n-nodes-base.set",
      "position": [
        -96,
        -124
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "af3e6c69-fbfe-49f4-9c29-3a68a821c5a6",
              "name": "project_id",
              "type": "string",
              "value": "n8n-project-467007"
            },
            {
              "id": "1a693ae0-2ba0-4b1b-a00a-4399a8d3ab57",
              "name": "location",
              "type": "string",
              "value": "asia-southeast1"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "771db667-e53d-44da-9493-62aac39fbf6c",
      "name": "获取给定项目的存储桶列表",
      "type": "n8n-nodes-base.googleCloudStorage",
      "position": [
        128,
        -272
      ],
      "parameters": {
        "projectId": "={{ $json.project_id }}",
        "requestOptions": {}
      },
      "credentials": {
        "googleCloudStorageOAuth2Api": {
          "id": "SW5pWMqnAkS2RL3K",
          "name": "Google Cloud Storage account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "cc89fc60-4a79-45f9-af40-99425e9eb1e9",
      "name": "创建新存储桶",
      "type": "n8n-nodes-base.googleCloudStorage",
      "position": [
        128,
        24
      ],
      "parameters": {
        "createAcl": {},
        "operation": "create",
        "projectId": "={{ $json.project_id }}",
        "bucketName": "=bucket{{ $workflow.id.toLowerCase() }}{{ $now.format('hhmm') }}",
        "createBody": {
          "dataLocations": "=[ {{ $json.location }}]"
        },
        "requestOptions": {}
      },
      "credentials": {
        "googleCloudStorageOAuth2Api": {
          "id": "SW5pWMqnAkS2RL3K",
          "name": "Google Cloud Storage account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b23df0ef-1fa9-41b4-97dd-9493f58ca7af",
      "name": "无操作,不执行任何动作",
      "type": "n8n-nodes-base.noOp",
      "position": [
        440,
        -272
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "bbda235c-aecb-4d0b-9174-eb5046017402",
      "name": "创建对象",
      "type": "n8n-nodes-base.googleCloudStorage",
      "position": [
        976,
        24
      ],
      "parameters": {
        "resource": "object",
        "operation": "create",
        "bucketName": "={{ $('Create a new Bucket').item.json.name }}",
        "createData": {},
        "objectName": "=object_{{ $now.format('yyyyMMdd') }}.{{ $json.fileExtension }}",
        "createQuery": {},
        "requestOptions": {},
        "encryptionHeaders": {}
      },
      "credentials": {
        "googleCloudStorageOAuth2Api": {
          "id": "SW5pWMqnAkS2RL3K",
          "name": "Google Cloud Storage account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "4c62f2ea-3891-46fd-bd3c-f3b9cabe2566",
      "name": "从存储桶中删除对象",
      "type": "n8n-nodes-base.googleCloudStorage",
      "position": [
        1200,
        24
      ],
      "parameters": {
        "resource": "object",
        "operation": "delete",
        "bucketName": "={{ $json.bucket }}",
        "objectName": "={{ $json.name }}",
        "getParameters": {},
        "requestOptions": {}
      },
      "credentials": {
        "googleCloudStorageOAuth2Api": {
          "id": "SW5pWMqnAkS2RL3K",
          "name": "Google Cloud Storage account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0f7d43ea-ca03-4fb5-a13c-ce238a16158d",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1680,
        -640
      ],
      "parameters": {
        "width": 1200,
        "height": 1280,
        "content": "# 初学者教程:使用 n8n 管理 Google Cloud Storage 存储桶和对象"
      },
      "typeVersion": 1
    },
    {
      "id": "583e8c1e-2656-4826-a44f-3473e2ce63df",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -400,
        -304
      ],
      "parameters": {
        "width": 352,
        "height": 112,
        "content": "### 1. 启动工作流"
      },
      "typeVersion": 1
    },
    {
      "id": "93a9d84f-15ee-4abc-88b2-2ded850d044d",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -176,
        48
      ],
      "parameters": {
        "height": 128,
        "content": "### 2. 提供输入字段"
      },
      "typeVersion": 1
    },
    {
      "id": "54648e02-71b1-4cb9-93c1-0911a8752a27",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        96,
        -512
      ],
      "parameters": {
        "height": 192,
        "content": "### 3. 列出所有当前 Google Cloud Storage 存储桶"
      },
      "typeVersion": 1
    },
    {
      "id": "2102a37c-3c07-4629-b31e-24b1d093973d",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        240
      ],
      "parameters": {
        "height": 128,
        "content": "### 4. 创建新存储桶"
      },
      "typeVersion": 1
    },
    {
      "id": "401fb591-bb05-484c-8b50-48ad51f68e60",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        352,
        -144
      ],
      "parameters": {
        "width": 496,
        "content": "### 5. 生成 AI 提示"
      },
      "typeVersion": 1
    },
    {
      "id": "8129411b-27a2-4d11-ab54-e73a7af4042c",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        912,
        240
      ],
      "parameters": {
        "height": 144,
        "content": "### 7. 上传图像到存储桶"
      },
      "typeVersion": 1
    },
    {
      "id": "a6246de7-0736-4040-af21-18b337e3e524",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1184,
        -176
      ],
      "parameters": {
        "content": "### 8. 删除对象(可选)"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "3f6f80f3-c6fd-4640-b5c2-2f3c89eec940",
  "connections": {
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Get a list of Buckets for a given project",
            "type": "main",
            "index": 0
          },
          {
            "node": "Create a new Bucket",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create an object": {
      "main": [
        [
          {
            "node": "Delete an object from a bucket",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate an image": {
      "main": [
        [
          {
            "node": "Create an object",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Prompt Generation Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Create a new Bucket": {
      "main": [
        [
          {
            "node": "Prompt Generation Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prompt Generation Agent": {
      "main": [
        [
          {
            "node": "Generate an image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get a list of Buckets for a given project": {
      "main": [
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 文件管理, 多模态 AI

需要付费吗?

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

工作流信息
难度等级
高级
节点数量18
分类2
节点类型8
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Trung Tran

Trung Tran

@trungtran

Empowering small and medium businesses with smart automation and practical AI, no big tech team required.

外部链接
在 n8n.io 查看

分享此工作流