FTP/SFTP Client
通过 FTP/SFTP 传输文件。
通过 FTP、FTPS 或 SFTP 列出、上传、下载或删除单个远程文件,凭据在服务器端解析。
工作原理
- 解析配置。
connection_id、operation(默认list)、remotePath和fileContent缺失时回退到输入 payload 中的同名键。 - 解析凭据:
host(默认127.0.0.1)、port、protocol和secure取自凭据配置;username和password取自凭据密钥。 - 选择协议:端口为 22 或 2222、或
protocol为sftp时使用 SFTP;否则使用 FTP(secure为 true 时使用 FTPS)。凭据未设置端口时,SFTP 使用 22,FTP 使用 21。 - 执行操作:
list(列出remotePath目录)、upload(将fileContent写入remotePath)、download(以 UTF-8 文本读取remotePath)或delete。 - 从
out返回{ result },关闭连接,并将协议错误发送到error。
在工作流中
节点在工作流文件(draft_nodes[])中的写法,以及一次成功运行的 envelope。
{
"node_id": "node-download-orders",
"label": "Download orders file",
"operator_slug": "io.ftp",
"operator_version": "1.0.0",
"config": {
"connection_id": "pi-credential-xxxx",
"operation": "download",
"remotePath": "/outbound/orders-{{ $json.date }}.csv"
}
}{
"ok": true,
"data": {
"result": {
"content": "order_id,amount\nord_123,250.00\n"
}
},
"port": "out"
}配置
-
connection_idstring 必填 -
FTP/SFTP 服务器的凭据。接受 `basic-auth`(用户名 + 密码 + 主机 + 端口)或 `connection-string`(ftp:// / sftp:// URI)类型的凭据。
-
operationstring 必填 -
remotePathstring 可选 -
localPathstring 可选 -
用于上传/下载
-
fileContentstring 可选 -
用于上传的直接内容
代码中的行为
除 schema 描述之外,实现代码对这些键的实际处理。
-
connection_id - 接受
basic-auth凭据:其配置包含host、port、protocol(设为sftp可强制使用 SFTP)和secure,密钥包含username和password。connection-string类型的密钥(ftp://URI)不会被解析,主机和端口必须写在凭据配置中。以{开头的值会被解析为内联 JSON{ config, credentials },而非凭据 id;仅限本地测试使用。 -
localPath - 已声明但被忽略:上传读取
fileContent,下载在输出中返回内容,不会读写本地磁盘。 -
remotePath - 为空时,
list使用/(FTP)或.(SFTP)。 -
port代码会读取,但未声明 - 未声明,仅作提示读取:凭据未设置端口且节点配置为
port: 22时,使用端口 22 的 SFTP。
输出端口
out 默认 操作成功。list 时 result 为条目数组,download 时为 { content },upload 时为 { uploaded: true, path },delete 时为 { deleted: true }。FTP 列表条目包含库提供的文件信息(name、type:1 = 文件,2 = 目录、size、rawModifiedAt 等);SFTP 条目仅含 name、type 和 size。
{
"result": [
{
"name": "orders-2026-11-25.csv",
"type": 1,
"size": 18342
},
{
"name": "archive",
"type": 2,
"size": 4096
}
]
}error 登录、传输或路径错误,操作缺少参数,不支持的操作,或 SFTP 连接提前关闭。
{
"error": "remotePath is required for download"
}在表达式中
后续节点可通过 $("FTP/SFTP Client").item.json.<路径> 读取此节点输出中的内容(请把 FTP/SFTP Client 换成你的节点标签)。Editor 标记工作流编辑器在 Previous Nodes 中提示的路径(输出契约);Worker 标记 worker 实际通过 out 返回的路径,依据“端口”一节所示的输出。
| 表达式 | Editor | Worker |
|---|---|---|
$("FTP/SFTP Client").item.json.resultFTP 操作结果(例如列表或成功状态) |
错误
| 消息 | 端口 | 原因与处理 |
|---|---|---|
connection_id is required | error | 在连接前抛出,因此引擎会将该节点判定为失败(若无 flow.try 作用域捕获,整个运行也会失败)。请选择 FTP 或 SFTP 凭据。 |
Failed to resolve connection <connection_id>: <detail> | error | 凭据不存在或此工作流无权使用。同样会抛出异常,因此在 flow.try 作用域之外运行会失败。 |
fileContent is required for upload | error | FTP upload 缺少内容(路径缺失时 FTP 对应报 remotePath is required for upload 和 remotePath is required for download;SFTP 报 fileContent is required)。 |
Unsupported operation: <operation> | error | operation 不是 list、upload、download 或 delete。 |
SSH connection closed | error | SFTP 服务器在操作完成前关闭了连接,通常是因为登录被拒绝。 |
输入契约
-
connection_idstring 必填 -
operationstring 必填 -
remotePathstring 可选 -
localPathstring 可选 -
fileContentstring 可选
输出契约
-
resultobject 可选 -
FTP 操作结果(例如列表或成功状态)
契约(JSON Schema)
与编排器声明完全一致的定义。All 是完整的 *.definition.js;可与上方各节对照,找出文档与 schema 之间的差异。发布前可用它校验节点。
{
"slug": "io.ftp",
"name": "FTP/SFTP Client",
"category": "io",
"version": "1.0.0",
"description": "Transfer files via FTP/SFTP.",
"capabilities": [
"storage",
"ftp",
"sftp"
],
"config_schema": {
"type": "object",
"properties": {
"connection_id": {
"type": "string",
"title": "FTP / SFTP Credential",
"description": "Credential for the FTP/SFTP server. Accepts credentials of type `basic-auth` (username + password + host + port) or `connection-string` (ftp:// / sftp:// URI).",
"ui_widget": "connection_picker",
"ui_options": {
"credential_types": [
"basic-auth",
"connection-string"
],
"types": [
"ftp",
"sftp"
]
}
},
"operation": {
"type": "string",
"enum": [
"list",
"upload",
"download",
"delete"
],
"default": "list"
},
"remotePath": {
"type": "string"
},
"localPath": {
"type": "string",
"description": "For upload/download"
},
"fileContent": {
"type": "string",
"description": "Direct content for upload"
}
},
"required": [
"connection_id",
"operation"
]
},
"input_contract_schema": {
"type": "object",
"properties": {
"connection_id": {
"type": "string"
},
"operation": {
"type": "string"
},
"remotePath": {
"type": "string"
},
"localPath": {
"type": "string"
},
"fileContent": {
"type": "string"
}
},
"required": [
"connection_id",
"operation"
]
},
"output_contract_schema": {
"type": "object",
"properties": {
"result": {
"type": "object",
"description": "FTP operation result (e.g. list, or success)"
}
}
},
"ports": [
{
"port_id": "out",
"label": "Result",
"description": "Operation result",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "Transfer failed",
"is_default": false,
"supports_condition": false
}
],
"execution_mode": "async",
"required_resources": [],
"compatible_worker_pools": [
"standard-io"
],
"tags": [
"storage",
"legacy"
],
"is_stateful": false,
"publisher": {
"identity": "org_link_loom",
"profile": {
"name": "Link Loom",
"verified": true,
"url": "https://me.veripass.com/link-loom",
"logo_url": null
}
}
}{
"type": "object",
"properties": {
"connection_id": {
"type": "string",
"title": "FTP / SFTP Credential",
"description": "Credential for the FTP/SFTP server. Accepts credentials of type `basic-auth` (username + password + host + port) or `connection-string` (ftp:// / sftp:// URI).",
"ui_widget": "connection_picker",
"ui_options": {
"credential_types": [
"basic-auth",
"connection-string"
],
"types": [
"ftp",
"sftp"
]
}
},
"operation": {
"type": "string",
"enum": [
"list",
"upload",
"download",
"delete"
],
"default": "list"
},
"remotePath": {
"type": "string"
},
"localPath": {
"type": "string",
"description": "For upload/download"
},
"fileContent": {
"type": "string",
"description": "Direct content for upload"
}
},
"required": [
"connection_id",
"operation"
]
}{
"type": "object",
"properties": {
"connection_id": {
"type": "string"
},
"operation": {
"type": "string"
},
"remotePath": {
"type": "string"
},
"localPath": {
"type": "string"
},
"fileContent": {
"type": "string"
}
},
"required": [
"connection_id",
"operation"
]
}{
"type": "object",
"properties": {
"result": {
"type": "object",
"description": "FTP operation result (e.g. list, or success)"
}
}
}[
{
"port_id": "out",
"label": "Result",
"description": "Operation result",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "Transfer failed",
"is_default": false,
"supports_condition": false
}
]执行
- 执行方式
async- 有状态
- 否
- 凭据
- 在服务器端根据
connection_id解析,密钥不会进入工作流。 - 能力
storageftpsftp- 标签
storagelegacy
说明与限制
- 下载内容以 UTF-8 文本返回,二进制文件会损坏。上传时
fileContent以文本发送。 - SFTP 握手最多等待 15 秒。FTP 除库默认值外没有显式超时。不会重试。
- 凭据密钥在运行时于服务器端解析,不会出现在输出中。
已对照编排器代码核实 · 31e874b · 2026-11-26