Animatio Animatio
Animatio Animatio

Reputation: 36

Watch FTP folder via node.js

I need to watch ftp folder for files create/update/remove events. But I can't find any suitable solution to do this using node.js. Can you help me, please?

Upvotes: 0

Views: 3465

Answers (2)

Sharathi RB
Sharathi RB

Reputation: 877

You can use sftp-watcher modules. which will reduce your time.

https://www.npmjs.com/package/sftp-watcher

Upvotes: 0

stdob--
stdob--

Reputation: 29167

  1. You need get recursive listing of remote ftp directory and save it (look at https://github.com/mscdex/node-ftp and https://github.com/evanplaice/node-ftpsync)
  2. Set timeout to get new recursive listing
  3. Compare new and old listing (look at https://github.com/andreyvit/json-diff) and call handlers to the corresponding events
  4. Overwrite old listing with new
  5. Return to step two

Upvotes: 2

Related Questions