sftp-file-listener
v1.0.6
Published
SFTP listener to monitor the file changes using ssh2 client
Downloads
5
Maintainers
Readme
Sftp file watcher
SFTP file watcher monitors the SFTP directory provided and tigger corresponding event. It's easy to start and stop process at any time.
Configuration
Install package
npm install sftp-file-listener
SampleCode
var watcher = require('./sftp-file-listener');
var sftpConfig = {
clientName: "<client_name>", // a name string used in error messages
host: "127.0.0.1",
port: 22,
username: "user_name",
password: "password",
path: "path_to_listen",
filetypes: "file_types_filter", //optional
};
async function init() {
try {
var listener = await watcher.listen(sftpConfig);
listener.on("init", function (data) {
console.log(data);
});
listener.on("upload", function (data) {
console.log(data);
});
listener.on("error", async function (data) {
console.log(data);
});
// setTimeout(function () {
// console.log("calling stop");
// listener.emit("stop", true);
// }, 3000);
} catch (err) {
console.log(err.message);
}
}