8
n8n 中文网amn8n.com

Salesforce到S3文件迁移与清理

高级

这是一个File Management领域的自动化工作流,包含 23 个节点。主要使用 Code, AwsS3, Slack, Salesforce, HttpRequest 等节点。 Salesforce到S3文件迁移与清理

前置要求
  • AWS Access Key 和 Secret
  • Slack Bot Token 或 Webhook URL
  • Salesforce OAuth 凭证
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "9a562c06a632241f66aadd52a495ad98e76b760ef5cfce9c319a4759c47cd94e",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "aa8bd0f6-7e04-4036-be3d-7f43e5e4991b",
      "name": "由 Github 模型提供支持",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -900,
        -760
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "e4a7b64d-6456-4513-8589-67556f02e525",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -960,
        -540
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "9f084b45-0fe1-4f0d-bb56-ea44f8c67c3c",
      "name": "遍历每个文件记录",
      "type": "n8n-nodes-base.splitInBatches",
      "onError": "continueRegularOutput",
      "position": [
        -460,
        -765
      ],
      "parameters": {},
      "typeVersion": 3
    },
    {
      "id": "ed2f0e0e-972b-4b63-afad-81977286edab",
      "name": "下载文件内容",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -240,
        -840
      ],
      "parameters": {},
      "typeVersion": 4.2
    },
    {
      "id": "d9208cc6-b6ce-4622-8286-096f937239b7",
      "name": "上传至 S3",
      "type": "n8n-nodes-base.awsS3",
      "position": [
        -20,
        -840
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "bd48b8ba-6938-4a5d-8835-9c7af091af2e",
      "name": "从 ContentDocumentLink 获取 LinkedEntityId",
      "type": "n8n-nodes-base.salesforce",
      "position": [
        200,
        -840
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "90a3c105-8be3-4df2-b9d7-ac46ab20a9f2",
      "name": "过滤用户附件",
      "type": "n8n-nodes-base.code",
      "position": [
        420,
        -840
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "63c6798f-1e5f-40db-a950-c3f9652395c3",
      "name": "创建 S3_File__c 记录",
      "type": "n8n-nodes-base.salesforce",
      "position": [
        640,
        -840
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "e94a12c8-259a-4316-8e4e-5d7d9360cf55",
      "name": "准备要删除的 ContentDocumentId",
      "type": "n8n-nodes-base.code",
      "position": [
        860,
        -840
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "c72330d0-f318-44e7-9ce3-14e7729ae1f9",
      "name": "删除 Salesforce 中的原始文件",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1120,
        -840
      ],
      "parameters": {},
      "executeOnce": false,
      "typeVersion": 4.2
    },
    {
      "id": "2243b0b4-e417-4bef-8f93-db6b44824c78",
      "name": "发送Slack通知",
      "type": "n8n-nodes-base.slack",
      "position": [
        -240,
        -640
      ],
      "webhookId": "4daa0166-83c8-4212-9e5e-5a28ad464310",
      "parameters": {},
      "typeVersion": 2.3
    },
    {
      "id": "ba723f66-26d1-42aa-8cc4-e4fc7fd4300d",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -960,
        -1020
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "0e467508-4f89-45cd-aad2-0968a60ef0c0",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        -1120
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "509c7c42-44a3-445d-bcab-95d8594b62b2",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -500,
        -1020
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "2883bee3-098a-44c5-ae51-eb06c2d9c2ec",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -280,
        -1120
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "648e9af5-0f80-4fe5-80f9-2fafcf0dac8d",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -40,
        -1140
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "7063e250-8a74-4af2-bdc5-80f0802f0021",
      "name": "### 需要帮助?",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        -1180
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "a6cf774a-5042-4058-8699-674a8252f200",
      "name": "## 试试看!",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        380,
        -1180
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "9c28a0ef-2a38-47de-9311-68bc986046ac",
      "name": "GET 模型",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        600,
        -1140
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "a2c41a97-d84c-4008-9c02-5908f8cf8dbc",
      "name": "## 1. 创建新的自定义 OpenAI 凭据",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        800,
        -1080
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "5f16310f-30c4-4f7a-b537-a9e8961fda8d",
      "name": "便签10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1040,
        -1080
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "e61a28d8-6c62-479e-8991-1f60ed6ec7b9",
      "name": "便签 11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -280,
        -460
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "4915760a-e9b0-4c3f-bad4-2247fbfa208b",
      "name": "获取所有超过 365 天的 ContentDocuments",
      "type": "n8n-nodes-base.salesforce",
      "position": [
        -680,
        -760
      ],
      "parameters": {},
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Upload to S3": {
      "main": [
        [
          {
            "node": "Get LinkedEntityId from ContentDocumentLink",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get All ContentDocuments older than 365 days ago",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download File Content": {
      "main": [
        [
          {
            "node": "Upload to S3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create S3_File__c Record": {
      "main": [
        [
          {
            "node": "Prepare ContentDocumentId for Deletion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Each File Record": {
      "main": [
        [
          {
            "node": "Send Slack Notification",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download File Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Out User Attachments": {
      "main": [
        [
          {
            "node": "Create S3_File__c Record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Delete Original File in Salesforce": {
      "main": [
        [
          {
            "node": "Loop Over Each File Record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare ContentDocumentId for Deletion": {
      "main": [
        [
          {
            "node": "Delete Original File in Salesforce",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get LinkedEntityId from ContentDocumentLink": {
      "main": [
        [
          {
            "node": "Filter Out User Attachments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get All ContentDocuments older than 365 days ago": {
      "main": [
        [
          {
            "node": "Loop Over Each File Record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 文件管理

需要付费吗?

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

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

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

作者
Le Nguyen

Le Nguyen

@leeseifer

Salesforce Architect with 10+ years of experience in CRM, integrations, and automation. Skilled in Apex, LWC, REST APIs, and full-stack dev (JavaScript, .NET). I build secure, scalable workflows in n8n—connecting Salesforce, Stripe, and more. Passionate about lead scoring, data sync, and secure field masking. Certified Application Architect with deep expertise in platform, integration, and data architecture.

外部链接
在 n8n.io 查看

分享此工作流