Folder Watcher for new files

With the Server and/or the Client project. Is it possible to setup a folder watcher, so that when folks drop a new CSV or Excel file into the folder, it is read and uploaded to a database?

(My naive assumption right now, is that you would have to schedule a task to run every five minutes or so, see if there is a file in the folder, upload it, and then wipe the folder.). Probably that would haver some issues with race conditions.

It’s not possible to setup a folder watcher in EasyMorph. The recommended approach is to schedule a task to run every 5 minutes (or less frequent) and check the folder.

Hello Dmitry, would a faster file/folder watcher in the future be possible? We need a near real-time (few seconds) check on available files in a certain folder (and prefer to use EM to check this, instead of using an other tool)?

Yes, we will be adding Server triggers next year. One of the triggers will be Folder Watcher.

However, you can already reduce the delay to seconds with your own custom Folder Watcher. Create a workflow that does the following:

  • Generate a sequence from 1 to 11
  • Iterate another module for each line in the sequence

In the iterated module:

  • Wait 5 seconds
  • Check the target folder for new files
  • If there are new files, trigger a Server task that processes new files in asynchronous mode (i.e. without waiting for its result). The asynchronous mode is important because it shouldn't slow down the watcher workflow.

Schedule the workflow to run every 1 minute (60 seconds) on your Server. It will check for new files every 5 seconds.