8
n8n 中文网amn8n.com

直接从您的电子邮件创建、删除和组织AWS S3存储桶和文件

中级

这是一个File Management, Multimodal AI领域的自动化工作流,包含 15 个节点。主要使用 If, Code, AwsS3, Switch, EmailSend 等节点。 直接从您的电子邮件创建、删除和组织AWS S3存储桶和文件

前置要求
  • AWS Access Key 和 Secret
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "OO8dBG01EPaQGcVA",
  "meta": {
    "instanceId": "dd69efaf8212c74ad206700d104739d3329588a6f3f8381a46a481f34c9cc281",
    "templateCredsSetupCompleted": true
  },
  "name": "直接从您的电子邮件创建、删除和组织AWS S3存储桶和文件",
  "tags": [],
  "nodes": [
    {
      "id": "de49fbb0-5d1b-42ad-b500-beed9e895414",
      "name": "启动工作流(GET请求)",
      "type": "n8n-nodes-base.emailReadImap",
      "position": [
        0,
        920
      ],
      "parameters": {
        "options": {
          "customEmailConfig": "[\"UNSEEN\", [\"SUBJECT\", \"s3\"]]"
        }
      },
      "credentials": {
        "imap": {
          "id": "zTEGYssr7MSVeCs3",
          "name": "IMAP-test"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "4ab408d8-416d-4a39-91cd-3e06553c36a1",
      "name": "从电子邮件提取数据",
      "type": "n8n-nodes-base.code",
      "position": [
        220,
        920
      ],
      "parameters": {
        "jsCode": "const emailBody = $json[\"textPlain\"] || \"\";\n\n// Helper function to match patterns\nfunction matchFirst(patterns) {\n  for (const pattern of patterns) {\n    const match = emailBody.match(pattern);\n    if (match) return match[1];\n  }\n  return null;\n}\n\n// Detect bucket name\nconst bucket = matchFirst([\n  /bucket[:\\s*]*([a-z0-9.-]+)/i,\n  /on bucket\\s+([a-z0-9.-]+)/i\n]);\n\n// Detect file name\nconst fileName = matchFirst([\n  /file[:\\s*]*([^\\s]+)/i,\n  /named\\s+([^\\s]+)/i\n]);\n\n// Detect source file (for copy)\nconst sourceFile = matchFirst([\n  /source\\s+([^\\s]+)/i\n]);\n\n// Detect destination file (for copy)\nconst destFile = matchFirst([\n  /destination\\s+([^\\s]+)/i\n]);\n\n// Decide task type\nlet task_type = null;\nif (/create bucket/i.test(emailBody)) task_type = \"create_bucket\";\nelse if (/delete bucket/i.test(emailBody)) task_type = \"delete_bucket\";\nelse if (/copy file/i.test(emailBody)) task_type = \"copy_file\";\nelse if (/delete file/i.test(emailBody)) task_type = \"delete_file\";\nelse if (/download file/i.test(emailBody)) task_type = \"download_file\";\nelse if (/upload file/i.test(emailBody)) task_type = \"upload_file\";\nelse if (/list files/i.test(emailBody)) task_type = \"get_files\";\n\nreturn [\n  {\n    json: {\n      bucket,\n      fileName,\n      sourceFile,\n      destFile,\n      task_type\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "d2926988-4e41-4d5e-84e2-75893ed04565",
      "name": "创建存储桶",
      "type": "n8n-nodes-base.awsS3",
      "position": [
        660,
        320
      ],
      "parameters": {
        "name": "new-project",
        "resource": "bucket",
        "additionalFields": {}
      },
      "credentials": {
        "aws": {
          "id": "KRRqQf7ufs26Mvaq",
          "name": "AWS account - test"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "1401cf3e-62c1-44db-bca6-29231f3add1e",
      "name": "删除存储桶",
      "type": "n8n-nodes-base.awsS3",
      "position": [
        660,
        520
      ],
      "parameters": {
        "name": "new-project",
        "resource": "bucket",
        "operation": "delete"
      },
      "credentials": {
        "aws": {
          "id": "KRRqQf7ufs26Mvaq",
          "name": "AWS account - test"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "43d9a1bb-6ad5-4916-91ef-0e9df365d8f4",
      "name": "复制文件",
      "type": "n8n-nodes-base.awsS3",
      "position": [
        660,
        720
      ],
      "parameters": {
        "operation": "copy",
        "sourcePath": "/old/old-project-image.jpg",
        "destinationPath": "/new/new-project-image.jpg",
        "additionalFields": {}
      },
      "credentials": {
        "aws": {
          "id": "KRRqQf7ufs26Mvaq",
          "name": "AWS account - test"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "b7af67ad-ba3d-41fe-96fc-3613f332a1fa",
      "name": "上传文件",
      "type": "n8n-nodes-base.awsS3",
      "position": [
        660,
        1320
      ],
      "parameters": {
        "fileName": "/new/new-project-image.jpg",
        "operation": "upload",
        "bucketName": "new-project",
        "additionalFields": {}
      },
      "credentials": {
        "aws": {
          "id": "KRRqQf7ufs26Mvaq",
          "name": "AWS account - test"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "e8290bcc-0816-421d-bea3-e588809d63b9",
      "name": "获取多个文件",
      "type": "n8n-nodes-base.awsS3",
      "position": [
        660,
        1520
      ],
      "parameters": {
        "options": {},
        "operation": "getAll",
        "bucketName": "={{ $json.bucket }}"
      },
      "credentials": {
        "aws": {
          "id": "KRRqQf7ufs26Mvaq",
          "name": "AWS account - test"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "cd585a21-6073-4a59-a157-943360266ac4",
      "name": "下载文件",
      "type": "n8n-nodes-base.awsS3",
      "position": [
        660,
        1120
      ],
      "parameters": {
        "fileKey": "/new/new-project-image.jpg",
        "bucketName": "new-project"
      },
      "credentials": {
        "aws": {
          "id": "KRRqQf7ufs26Mvaq",
          "name": "AWS account - test"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "33819696-4b09-45c8-b938-0a929281be26",
      "name": "删除文件",
      "type": "n8n-nodes-base.awsS3",
      "position": [
        660,
        920
      ],
      "parameters": {
        "fileKey": "/new/new-project-image.jpg",
        "options": {},
        "operation": "delete",
        "bucketName": "new-project-image"
      },
      "credentials": {
        "aws": {
          "id": "KRRqQf7ufs26Mvaq",
          "name": "AWS account - test"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "ae71cb97-4e9e-4733-a024-990045bed90f",
      "name": "检查任务类型",
      "type": "n8n-nodes-base.switch",
      "position": [
        440,
        836
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "99e9f0b2-e19b-45c5-a60e-317d772e6291",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.task_type }}",
                    "rightValue": "create_bucket"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "4e72b4c7-eed9-4039-84c7-773a4dee2eb6",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.task_type }}",
                    "rightValue": "delete_bucket"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "aef1b8b8-9175-4819-9cb8-87209e4b2954",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.task_type }}",
                    "rightValue": "copy_file"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "a256941b-0882-4ee1-9126-491da78f5fb4",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.task_type }}",
                    "rightValue": "delete_file"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "a502de56-2efa-4766-b883-65d8cefaab1a",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.task_type }}",
                    "rightValue": "download_file"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "62aae8fd-71f2-4194-af78-b8d42179a2d0",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.task_type }}",
                    "rightValue": "upload_file"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "e70fb51d-7d2e-4ed2-bdde-7edd03059033",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.task_type }}",
                    "rightValue": "get_files"
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "a3b10fac-ff46-4aac-9683-949c4c6246c8",
      "name": "发送失败邮件",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        1100,
        1020
      ],
      "webhookId": "2c315c54-22bb-49c5-8f74-5f32569b8821",
      "parameters": {
        "text": "=AWS S3 Operation Failed",
        "options": {
          "replyTo": "={{ $('Start Workflow (GET Request)').item.json.from }}"
        },
        "subject": "=AWS S3 Operation Failed",
        "toEmail": "={{ $('Start Workflow (GET Request)').item.json.from }}",
        "fromEmail": "xyz@gmail.com",
        "emailFormat": "text"
      },
      "credentials": {
        "smtp": {
          "id": "G1kyF8cSWTZ4vouN",
          "name": "SMTP -test"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "7c01eb42-56e7-431e-ba13-9fa8b88cb84f",
      "name": "发送成功邮件",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        1100,
        820
      ],
      "webhookId": "2c315c54-22bb-49c5-8f74-5f32569b8821",
      "parameters": {
        "text": "=AWS S3 Operation Successful",
        "options": {
          "replyTo": "={{ $('Start Workflow (GET Request)').item.json.from }}"
        },
        "subject": "=AWS S3 Operation Successful",
        "toEmail": "={{ $('Start Workflow (GET Request)').item.json.from }}",
        "fromEmail": "xyz@gmail.com",
        "emailFormat": "text"
      },
      "credentials": {
        "smtp": {
          "id": "G1kyF8cSWTZ4vouN",
          "name": "SMTP -test"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "d79e2096-604a-441b-9697-6e308b3002f5",
      "name": "检查-成功或失败",
      "type": "n8n-nodes-base.if",
      "position": [
        880,
        920
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "045a2b56-33db-45b3-8c14-ad7d0ba64db7",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.Key }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2,
      "alwaysOutputData": true
    },
    {
      "id": "d6872864-93fc-462a-8693-41377e283d37",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        380
      ],
      "parameters": {
        "width": 1000,
        "height": 140,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "c19d98fb-6112-4886-807f-c78f5aead7be",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -680,
        760
      ],
      "parameters": {
        "color": 4,
        "width": 560,
        "height": 400,
        "content": "## 工作原理"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "2bdf2886-f43d-4a91-853c-f40359658edd",
  "connections": {
    "43d9a1bb-6ad5-4916-91ef-0e9df365d8f4": {
      "main": [
        [
          {
            "node": "d79e2096-604a-441b-9697-6e308b3002f5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "33819696-4b09-45c8-b938-0a929281be26": {
      "main": [
        [
          {
            "node": "d79e2096-604a-441b-9697-6e308b3002f5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "b7af67ad-ba3d-41fe-96fc-3613f332a1fa": {
      "main": [
        [
          {
            "node": "d79e2096-604a-441b-9697-6e308b3002f5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "e8290bcc-0816-421d-bea3-e588809d63b9": {
      "main": [
        [
          {
            "node": "d79e2096-604a-441b-9697-6e308b3002f5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ae71cb97-4e9e-4733-a024-990045bed90f": {
      "main": [
        [
          {
            "node": "d2926988-4e41-4d5e-84e2-75893ed04565",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "1401cf3e-62c1-44db-bca6-29231f3add1e",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "43d9a1bb-6ad5-4916-91ef-0e9df365d8f4",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "33819696-4b09-45c8-b938-0a929281be26",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "cd585a21-6073-4a59-a157-943360266ac4",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "b7af67ad-ba3d-41fe-96fc-3613f332a1fa",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "e8290bcc-0816-421d-bea3-e588809d63b9",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d2926988-4e41-4d5e-84e2-75893ed04565": {
      "main": [
        [
          {
            "node": "d79e2096-604a-441b-9697-6e308b3002f5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1401cf3e-62c1-44db-bca6-29231f3add1e": {
      "main": [
        [
          {
            "node": "d79e2096-604a-441b-9697-6e308b3002f5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "cd585a21-6073-4a59-a157-943360266ac4": {
      "main": [
        [
          {
            "node": "d79e2096-604a-441b-9697-6e308b3002f5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d79e2096-604a-441b-9697-6e308b3002f5": {
      "main": [
        [
          {
            "node": "7c01eb42-56e7-431e-ba13-9fa8b88cb84f",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "a3b10fac-ff46-4aac-9683-949c4c6246c8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4ab408d8-416d-4a39-91cd-3e06553c36a1": {
      "main": [
        [
          {
            "node": "ae71cb97-4e9e-4733-a024-990045bed90f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "de49fbb0-5d1b-42ad-b500-beed9e895414": {
      "main": [
        [
          {
            "node": "4ab408d8-416d-4a39-91cd-3e06553c36a1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

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

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

作者
Oneclick AI Squad

Oneclick AI Squad

@oneclick-ai

The AI Squad Initiative is a pioneering effort to build, automate and scale AI-powered workflows using n8n.io. Our mission is to help individuals and businesses integrate AI agents seamlessly into their daily operations from automating tasks and enhancing productivity to creating innovative, intelligent solutions. We design modular, reusable AI workflow templates that empower creators, developers and teams to supercharge their automation with minimal effort and maximum impact.

外部链接
在 n8n.io 查看

分享此工作流

分类

分类: 34