Socket
Book a DemoInstallSign in
Socket

sftp-file-listener

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sftp-file-listener

SFTP listener to monitor the file changes using ssh2 client

1.0.6
latest
npmnpm
Version published
Maintainers
1
Created
Source

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);
    }
}

Keywords

SFTP

FAQs

Package last updated on 17 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.