Read/Write Files from Disk#
Use the Read/Write Files from Disk node to read and write files from/to the machine where n8n is running.
The paths this node can access depend on your n8n deployment. Refer to File locations for details.
Operations#
- Read File(s) From Disk: Use this operation to retrieve one or more files from the computer that runs 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.[]: Matches any characters inside the brackets. For example,[abc]would match the charactersa,b, orc, and nothing else.
- To enter multiple files, enter a page path pattern. You can use these characters to define a path pattern:
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 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#
The paths this node can read from and write to depend on your n8n deployment.
n8n Cloud#
On n8n Cloud, the node can only access paths under /home/node/. Paths outside this directory (for example, /tmp/ or /data/) fail with an access error.
Field placeholders on Cloud
The default placeholders in the node's File(s) Selector and File Path and Name fields (such as /home/user/Pictures/**/*.png and /data/example.jpg) are examples. On Cloud, replace them with a path under /home/node/.
Cloud filesystem is ephemeral
Files this node writes on Cloud aren't guaranteed to persist across workflow executions, worker restarts, or instance redeploys. Don't use this node to store files you need to keep.
n8n reserves the /home/node/.n8n/ directory for its internal state. Don't write your own files there.
For persistent file handling on Cloud, use a cloud storage node such as AWS S3, Google Drive, or FTP.
Self-hosted n8n#
On self-hosted n8n, by default the node can access any path the n8n process can reach. To restrict access, set the N8N_RESTRICT_FILE_ACCESS_TO environment variable to one or more allowed directories (semicolon-separated).
Default changes in n8n 2.0
Starting in n8n 2.0, N8N_RESTRICT_FILE_ACCESS_TO defaults to ~/.n8n-files. To allow file operations elsewhere, set the variable explicitly. Refer to n8n 2.0 breaking changes for details.
If you run n8n in Docker, paths refer to the n8n container's filesystem, not the Docker host. To make host directories available to this node, mount them as volumes into the container.
n8n recommends using absolute file paths to prevent errors.