8
n8n 中文网amn8n.com

已发布:[子流程] Dropbox 上传链接

高级

这是一个File Management领域的自动化工作流,包含 19 个节点。主要使用 If, Set, Dropbox, DataTable, FormTrigger 等节点。 上传文件到 Dropbox 并生成直接下载链接

前置要求
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "McIM3fyCBUnCR97N",
  "meta": {
    "instanceId": "42bde649da4575cc0d49afcf8affcdbece40e5e40061aa2c9b7a8b3639284dfe"
  },
  "name": "已发布:[子流程] Dropbox 上传链接",
  "tags": [],
  "nodes": [
    {
      "id": "50809acd-5528-44cf-b2d8-993cddae08a9",
      "name": "当被其他工作流执行时",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -1568,
        -16
      ],
      "parameters": {
        "inputSource": "passthrough"
      },
      "typeVersion": 1.1
    },
    {
      "id": "eacbf743-344e-4ec7-8711-bbf3cbd28b27",
      "name": "标准化路径1",
      "type": "n8n-nodes-base.set",
      "position": [
        -1264,
        -16
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "5b40d0d7-f20f-4510-9e1a-05d5db31f4aa",
      "name": "上传和路径处理1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1568,
        -192
      ],
      "parameters": {
        "color": 4,
        "width": 416,
        "content": "## 上传与路径处理"
      },
      "typeVersion": 1
    },
    {
      "id": "72d5f167-520b-417b-b2c0-0cd00f34c296",
      "name": "分享链接管理1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1008,
        -256
      ],
      "parameters": {
        "color": 2,
        "width": 480,
        "height": 224,
        "content": "## 共享链接管理"
      },
      "typeVersion": 1
    },
    {
      "id": "98b3b6d6-9918-46bf-bb71-569088f54081",
      "name": "直接链接处理1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -448,
        -192
      ],
      "parameters": {
        "color": 5,
        "width": 496,
        "content": "## 直接链接处理"
      },
      "typeVersion": 1
    },
    {
      "id": "9678708f-8a78-423b-8877-4cb98814fe37",
      "name": "Dropbox:创建共享链接",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -432,
        144
      ],
      "parameters": {
        "url": "https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"path\": \"{{ $('Normalize Path1').item.json.path_lower }}\",\n  \"settings\": {\n    \"requested_visibility\": \"public\"\n  }\n}\n",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $json.token }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "d873e83d-7d0e-4264-bf4e-93700ae3c88c",
      "name": "如果:链接存在?",
      "type": "n8n-nodes-base.if",
      "position": [
        -688,
        -16
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "ce8a640e-90ae-4337-9110-0e23262a649c",
              "operator": {
                "type": "string",
                "operation": "empty",
                "singleValue": true
              },
              "leftValue": "={{ $json.links[0].url }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "ab00f2f0-5e52-4213-9ab1-4e03eb6a42b2",
      "name": "提取现有链接",
      "type": "n8n-nodes-base.set",
      "position": [
        -832,
        -16
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "cb96c7eb-763d-4cd6-9198-bc7b54bf1f00",
      "name": "Dropbox:列出共享链接",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -992,
        -16
      ],
      "parameters": {
        "url": "https://api.dropboxapi.com/2/sharing/list_shared_links",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"path\": \"{{ $json.path_lower }}\",\n  \"direct_only\": true\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "dropboxOAuth2Api"
      },
      "credentials": {
        "oAuth2Api": {
          "id": "WFxoxqeBfeh341Mm",
          "name": "Dropbox2"
        },
        "dropboxOAuth2Api": {
          "id": "LimqAedb7vyPhqJ2",
          "name": "Dropbox account X"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "108812a1-f6e4-4fb6-838f-d6c43d2e7ec2",
      "name": "重写 Dropbox 主机",
      "type": "n8n-nodes-base.set",
      "position": [
        -432,
        16
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "574020e5-9928-41c0-be49-a58033dd8b3b",
      "name": "构建直接链接",
      "type": "n8n-nodes-base.set",
      "position": [
        -272,
        16
      ],
      "parameters": {
        "fields": {
          "values": [
            {
              "name": "shared_link_direct",
              "stringValue": "={{ String($json.links[0].url || '').trim().replace(/^https:\\/\\/(?:www\\.)?dropbox\\.com\\//, 'https://dl.dropboxusercontent.com/') }}"
            }
          ]
        },
        "include": "none",
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "4f2228ce-d31e-4a1a-bd55-c18d90851dc5",
      "name": "最终响应",
      "type": "n8n-nodes-base.set",
      "position": [
        -112,
        16
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "success_response",
              "name": "response",
              "type": "string",
              "value": "={{ $json.shared_link_direct }}"
            },
            {
              "id": "216b1279-56bc-45a5-9edd-3aeded1c516f",
              "name": "url",
              "type": "string",
              "value": "={{ $json.shared_link_direct }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "528ab43e-04f8-44e4-a4b4-64aba2d924c0",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1696,
        176
      ],
      "parameters": {
        "width": 608,
        "height": 576,
        "content": "## 在 Dropbox 上上传和托管的示例代码"
      },
      "typeVersion": 1
    },
    {
      "id": "2002c9c4-e6a6-4cd2-af23-bcfc0828d695",
      "name": "上传文件",
      "type": "n8n-nodes-base.dropbox",
      "position": [
        -1408,
        -16
      ],
      "parameters": {
        "path": "=/Automate/N8N/host/{{ $json['Upload file'][0].filename }}",
        "binaryData": true,
        "authentication": "oAuth2",
        "binaryPropertyName": "=Upload_file"
      },
      "credentials": {
        "dropboxOAuth2Api": {
          "id": "LimqAedb7vyPhqJ2",
          "name": "Dropbox account X"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "3da92dc4-669e-42eb-846c-d4e77462742e",
      "name": "获取 DropBox 访问令牌",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        -576,
        96
      ],
      "parameters": {
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "hZbk3Yqoqdn3lIJ4",
          "cachedResultUrl": "/projects/w1o5aCEZlpQzzMF5/datatables/hZbk3Yqoqdn3lIJ4",
          "cachedResultName": "cred-Dropbox"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "107a77a9-c3c7-4d5b-9e8c-5ce85fc62a6d",
      "name": "上传文件",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -848,
        576
      ],
      "webhookId": "dfc36d64-a5ed-49d7-952d-8287a1f26748",
      "parameters": {
        "options": {},
        "formTitle": "Upload File To DropBox",
        "formFields": {
          "values": [
            {
              "fieldType": "file",
              "fieldLabel": "Upload file",
              "requiredField": true
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "c85db16f-40dd-4a64-8bf4-84e4b7d449a7",
      "name": "已完成",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -480,
        576
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "7f00f7d0-bed1-4660-9e3d-5ed9284d7575",
      "name": "调用 '[子流程] Dropbox 上传链接'",
      "type": "n8n-nodes-base.executeWorkflow",
      "position": [
        -656,
        576
      ],
      "parameters": {
        "options": {},
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "DsRqr6QdhNM0TRaQ",
          "cachedResultUrl": "/workflow/DsRqr6QdhNM0TRaQ",
          "cachedResultName": "[SUB] Dropbox upload link"
        },
        "workflowInputs": {
          "value": {},
          "mappingMode": "defineBelow"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "35566c40-1451-4953-9935-6598baab7f94",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -864,
        432
      ],
      "parameters": {
        "width": 496,
        "height": 128,
        "content": "## 测试工作流"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "67f62d86-0ca8-4320-84a2-14c5c3e668fc",
  "connections": {
    "Upload File": {
      "main": [
        [
          {
            "node": "Call '[SUB] Dropbox upload links'",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload a file": {
      "main": [
        [
          {
            "node": "Normalize Path1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Path1": {
      "main": [
        [
          {
            "node": "Dropbox: List Shared Links",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If: Link Exists?": {
      "main": [
        [
          {
            "node": "Get DropBox access token",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Rewrite Dropbox Host",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Direct Link": {
      "main": [
        [
          {
            "node": "Final Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Rewrite Dropbox Host": {
      "main": [
        [
          {
            "node": "Build Direct Link",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Existing Link": {
      "main": [
        [
          {
            "node": "If: Link Exists?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get DropBox access token": {
      "main": [
        [
          {
            "node": "Dropbox: Create Shared Link",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Dropbox: List Shared Links": {
      "main": [
        [
          {
            "node": "Extract Existing Link",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Dropbox: Create Shared Link": {
      "main": [
        [
          {
            "node": "Dropbox: List Shared Links",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call '[SUB] Dropbox upload links'": {
      "main": [
        [
          {
            "node": "Completed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Upload a file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 文件管理

需要付费吗?

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

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

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

作者

I write code to save you headaches. I post workflows, that I had a hard time with or find was really needed. If you pay for one of my workflows, congratulations... it probably took me 10x the $$ amount in my personal time, figuring the darn thing out.

外部链接
在 n8n.io 查看

分享此工作流