I am attempting to react to new files being added to a directory, in order to process them through a workflow. I found the Local File Trigger node, which seems to be exactly what I need, however it does not trigger as expected.
I expect to get a file list of all the changed files that the filter catches.
What is the error message (if any)?
No error message, just the trigger not triggering (spinning forever). I can read the file contents with the Read Binary File node without issues. When checking the file parameters the updated field gets properly updated when I change the file.
Please share the workflow
Share the output returned by the last node
No data is outputted from the Local File Trigger node, however Read Binary File outputs everything correctly.
Information on your n8n setup
n8n version: 0.195.5
Database you’re using (default: SQLite): default
Running n8n with the execution process [own(default), main]: default
Running n8n via [Docker, npm, n8n.cloud, desktop app]: Docker
I had this problem at first and the reason why was that i had everything stored in the “my documents folder” which n8n couldnt read properly, so I moved n8n along with all its mounts into “home” and it worked fine afterwards.
just check if the volumes are mounted and that n8n can see the files using the execute command using “ls -ls”
@Josh-Ghazi I tried to set the Folder to Watch field to /home/node/input, instead of just /input, but that did not solve it.
I can poll the folder with ls -la /input (inside the docker container) and see the moved files and their updated timestamps, but the node itself does not trigger. The Read Binary File node still works great.
Perhaps it’s a n8n access issue or I have to set a relative path instead of an absolute one from the root? The documentation is not very clear on that and there are no example templates for this node.
I tested creating a file with touch /input/test.txt from inside the docker container and then the node triggered as expected, so I cannot manipulate files outside of the docker container and have the node react to it.
However, it seems I misunderstood the way the node works: I expected it to continue listening to events after being triggered, but it seems it stops after triggering once. So, beyond the fact that it doesn’t work for events outside of the docker container, it is not quite appropriate for what I intended (continuous triggering). I can probably do something similar using cron or an other method.
If you use the “Execute Workflow” button it will run once as that is designed for testing your workflow in the editor. On the top right there is an “Active” toggle next to the Save button, If this is set it will then run in the background.
I would expect it to work for files that are made outside of the container if they are going into the same mounted volume, I will give that a test. It could be that the os notifiers are not triggered in the same way, I will grab a coffee and take a quick look.
Alright back with a quick test result, In my container I have /files which is a volume with the host OS path being /home/docker/n8n-files.
I have set up a quick trigger that looks for any changes in /files then I have SSH’d to my docker host ran touch /home/docker/n8n-files/file.txt and it worked as expected so I popped in a Slack node to output the workflow name, Execution ID, Event and Path then activated the workflow and created a new file, added content to the file and made some folders.
It looks like the node is working with a Linux host running the standard docker image on 195.5, Out of interest what OS are you using for your host? It would be nice to try and get to the bottom of why it isn’t working on your setup.
To be complete the workflow below is what I have used.
That does look like it could be the case so maybe it is only an issue from a Mac host. The good news is in theory I should be able to reproduce that. I am surprised a bug like that from 2020 is still an issue.
Came here for the same issue. n8n in a Docker container on MacOS works fine with local file trigger. n8n in a container on Windows 10 doesn’t react to any file changes. An ls with the “Execute command” or “Read binary file” works fine.
To test further I logged into the container and created a simple JS file with a simple Chokidar watch folder. The result was the same: Nothing was triggered. When I added “usePolling: true” to the watch parameters then Chokidar behaved as expected. How can I add “usePolling: true” to the local file trigger? Or is there maybe another solution?