Local File System
在宿主机上读写文件。
在运行 worker 的主机文件系统上读取、写入、追加、删除或列出指定路径。
工作原理
- 解析配置。
path、operation(默认read)、content(默认为空)和encoding(默认utf8)缺失时回退到输入 payload 中的同名键。 path为空时从error失败输出。- 执行操作:
read以encoding解码并返回文件内容;write用content覆盖文件;append在末尾追加content;delete删除文件;list返回目录中的条目名称。 - 从
out返回{ result };任何文件系统错误都从error输出。
在工作流中
节点在工作流文件(draft_nodes[])中的写法,以及一次成功运行的 envelope。
{
"node_id": "node-write-export",
"label": "Write export",
"operator_slug": "io.local.file",
"operator_version": "1.0.0",
"config": {
"path": "/data/exports/orders-{{ $json.date }}.csv",
"operation": "write",
"content": "{{ $json.csv }}"
}
}{
"ok": true,
"data": {
"result": {
"written": true,
"path": "/data/exports/orders-2026-11-25.csv"
}
},
"port": "out"
}配置
-
pathstring 必填 -
绝对路径
-
operationstring 必填 -
contentstring 可选 -
要写入/追加的内容
-
encodingstring 可选
代码中的行为
除 schema 描述之外,实现代码对这些键的实际处理。
-
encoding - 仅对
read生效。write和append始终写入 UTF-8 文本。 -
path - 相对路径以编排器进程的工作目录为基准解析。
输出端口
out 默认 操作成功。read 时 result 为文本,list 时为名称数组,其他操作为 { written | appended | deleted: true, path }。
数据
{
"result": {
"written": true,
"path": "/data/exports/orders-2026-11-25.csv"
}
}error 缺少 path、操作未知,或文件系统拒绝了该调用。
数据
{
"error": "ENOENT: no such file or directory, open '/data/exports/missing.csv'"
}在表达式中
后续节点可通过 $("Local File System").item.json.<路径> 读取此节点输出中的内容(请把 Local File System 换成你的节点标签)。Editor 标记工作流编辑器在 Previous Nodes 中提示的路径(输出契约);Worker 标记 worker 实际通过 out 返回的路径,依据“端口”一节所示的输出。
| 表达式 | Editor | Worker |
|---|---|---|
$("Local File System").item.json.result文件内容或操作成功状态 | ||
$("Local File System").item.json.result.written | — | |
$("Local File System").item.json.result.path | — |
— Worker: worker 会返回它,但编辑器不会提示:请手动输入。对象内部的键可能取决于你的数据或配置(例如每个标签一个键)。
错误
| 消息 | 端口 | 原因与处理 |
|---|---|---|
path is required | error | 配置和输入 payload 中都没有路径。请使用绝对路径。 |
Unsupported operation: <operation> | error | operation 不是 read、write、append、delete 或 list。 |
ENOENT: no such file or directory, <syscall> '<path>' | error | 主机上不存在该文件或其父目录。write 和 append 不会创建缺失的目录。 |
EACCES: permission denied, <syscall> '<path>' | error | 编排器进程对该路径没有权限。 |
输入契约
-
pathstring 必填 -
operationstring 必填 -
contentstring 可选 -
encodingstring 可选
输出契约
-
resultstring 可选 -
文件内容或操作成功状态
契约(JSON Schema)
与编排器声明完全一致的定义。All 是完整的 *.definition.js;可与上方各节对照,找出文档与 schema 之间的差异。发布前可用它校验节点。
{
"slug": "io.local.file",
"name": "Local File System",
"category": "io",
"version": "1.0.0",
"description": "Read/Write files on host machine.",
"capabilities": [
"fs",
"local",
"file"
],
"config_schema": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "Absolute path"
},
"operation": {
"type": "string",
"enum": [
"read",
"write",
"append",
"delete",
"list"
],
"default": "read"
},
"content": {
"type": "string",
"description": "Content to write/append"
},
"encoding": {
"type": "string",
"default": "utf8"
}
},
"required": [
"path",
"operation"
]
},
"input_contract_schema": {
"type": "object",
"properties": {
"path": {
"type": "string"
},
"operation": {
"type": "string"
},
"content": {
"type": "string"
},
"encoding": {
"type": "string"
}
},
"required": [
"path",
"operation"
]
},
"output_contract_schema": {
"type": "object",
"properties": {
"result": {
"type": "string",
"description": "File content or operation success status"
}
}
},
"ports": [
{
"port_id": "out",
"label": "Result",
"description": "FS operation succeeded",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "FS operation failed",
"is_default": false,
"supports_condition": false
}
],
"execution_mode": "async",
"required_resources": [],
"compatible_worker_pools": [
"desktop-agent",
"local-agent"
],
"tags": [
"local",
"files"
],
"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": {
"path": {
"type": "string",
"description": "Absolute path"
},
"operation": {
"type": "string",
"enum": [
"read",
"write",
"append",
"delete",
"list"
],
"default": "read"
},
"content": {
"type": "string",
"description": "Content to write/append"
},
"encoding": {
"type": "string",
"default": "utf8"
}
},
"required": [
"path",
"operation"
]
}{
"type": "object",
"properties": {
"path": {
"type": "string"
},
"operation": {
"type": "string"
},
"content": {
"type": "string"
},
"encoding": {
"type": "string"
}
},
"required": [
"path",
"operation"
]
}{
"type": "object",
"properties": {
"result": {
"type": "string",
"description": "File content or operation success status"
}
}
}[
{
"port_id": "out",
"label": "Result",
"description": "FS operation succeeded",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "FS operation failed",
"is_default": false,
"supports_condition": false
}
]执行
- 执行方式
async- 有状态
- 否
- 能力
fslocalfile- 标签
localfiles
说明与限制
- 路径指向运行 worker 的主机或容器,其环境可能是临时的;写入的文件在重新部署后不会保留。
write会直接覆盖且不提示确认,delete不可恢复。list不递归。
已对照编排器代码核实 · 31e874b · 2026-11-26