从磁盘读取/写入文件#
¥Read/Write Files from Disk
使用磁盘文件读写节点从运行 n8n 的机器读取和写入文件。
¥Use the Read/Write Files from Disk node to read and write files from/to the machine where n8n is running.
Self-hosted n8n only
此节点在 n8n Cloud 上不可用。
¥This node isn't available on n8n Cloud.
操作#
¥Operations
- 从磁盘读取文件:使用此操作从运行 n8n 的计算机检索一个或多个文件。
¥Read File(s) From Disk: Use this operation to retrieve one or more files from the computer that runs n8n.
- 将文件写入磁盘:使用此操作在运行 n8n 的计算机上创建二进制文件。
¥Write File to Disk: Use this operation to create a binary file on the computer that runs n8n.
有关配置每个操作的节点的更多信息,请参阅以下章节。
¥Refer to the sections below for more information on configuring the node for each operation.
从磁盘读取文件#
¥Read File(s) From Disk
使用以下参数配置此操作:
¥Configure this operation with these parameters:
- 文件选择器:输入要读取的文件的路径。
¥File(s) Selector: Enter the path of the file you want to read.
-
要输入多个文件,请输入页面路径模式。你可以使用以下字符定义路径模式:
¥To enter multiple files, enter a page path pattern. You can use these characters to define a path pattern:
*:匹配除路径分隔符外的任何字符零次或多次。
¥
*: Matches any character zero or more times, excluding path separators.**:匹配任意字符零次或多次,包括路径分隔符。
¥
**: Matches any character zero or more times, include path separators.?:匹配除路径分隔符外的任何字符一次。
¥
?: Matches any character except for path separators one time.[]:匹配方括号内的任何字符。例如,[abc]会匹配字符a、b或c,不匹配其他任何字符。
¥
[]: Matches any characters inside the brackets. For example,[abc]would match the charactersa,b, orc, and nothing else.
有关这些字符及其预期行为的更多信息,请参阅 Picomatch 基本通配符 文档。
¥Refer to Picomatch's Basic globbing documentation for more information on these characters and their expected behavior.
从磁盘读取文件选项#
¥Read File(s) From Disk options
你还可以使用以下选项配置此操作:
¥You can also configure this operation with these Options:
- 文件扩展名:输入节点输出中文件的扩展名。
¥File Extension: Enter the extension for the file in the node output.
- 文件名:输入节点输出中文件的名称。
¥File Name: Enter the name for the file in the node output.
- MIME 类型:在节点输出中输入文件的 MIME 类型。请参阅 常用 MIME 类型 获取文件扩展名及其对应的 MIME 类型列表。
¥MIME Type: Enter the file's MIME type in the node output. Refer to Common MIME types for a list of file extensions and their MIME types.
- 将输出文件放入字段:输入输出数据中用于存储文件的字段名称。
¥Put Output File in Field: Enter the name of the field in the output data to contain the file.
将文件写入磁盘#
¥Write File to Disk
使用以下参数配置此操作:
¥Configure this operation with these parameters:
- 文件路径和名称:请输入文件目标位置、文件名和文件扩展名。
¥File Path and Name: Enter the destination for the file, the file's name, and the file's extension.
- 输入二进制字段:输入节点输入数据中用于存储二进制文件的字段名称。
¥Input Binary Field: Enter the name of the field in the node input data that will contain the binary file.
将文件写入磁盘选项#
¥Write File to Disk options
你还可以使用以下选项配置此操作:
¥You can also configure this operation with these Options:
此操作包含一个选项,用于选择是将数据追加到现有文件而不是创建新文件(已启用),还是创建新文件而不是追加到现有文件(已禁用)。
¥This operation includes a single option, whether to Append data to an existing file instead of creating a new one (turned on) or to create a new file instead of appending to existing (turned off).
模板和示例#
¥Templates and examples
文件位置#
¥File locations
如果你在 Docker 中运行 n8n,则你的命令将在 n8n 容器中运行,而不是在 Docker 主机中运行。
¥If you run n8n in Docker, your command runs in the n8n container and not the Docker host.
此节点会查找相对于 n8n 安装路径的文件。n8n 建议使用绝对文件路径以避免任何错误。
¥This node looks for files relative to the n8n install path. n8n recommends using absolute file paths to prevent any errors.