remote-file-watcher

1.0.6 • Public • Published

remote-file-watcher

Keeping an eye on file uploads

What is the remote file watcher?

The remote file watcher was developed as a way to easily monitor multiple directories on multiple servers for new file uploads and the removal of files. It is extremely easy to use. Just provide an object of connection details for the server containing a group of directories to monitor and when a file is uploaded or delete an event is emitted. At the moment an SFTP connection is used only. More connection type support is planned for development.

Example usage

Below is an example of how to instantiate the class, providing the config object, and listen for the 3 events that are currently emitted:

    const remoteFileWatcher = require('remote-file-watcher');
    
    var objConfig = {
        host: '192.168.1.10',
        port: 22,
        username: 'server_username',
        password: 'server_password',
        algorithms: {
            serverHostKey: [ 'ssh-rsa', 'ssh-dss' ],
        },
        folders : {
            0 : '/var/www/html/DirectoryOne',
            1 : '/Uploads/DirectoryTwo'
        },
        //debug: console.log
    }
    
    const objRemoteFileWatcher = new remoteFileWatcher('my_server_name', objConfig);
    
    objRemoteFileWatcher.on('uploading', function (objFile) {
    
        console.log('FILE UPLOADING:');
        console.log(objFile);
    });
    
    objRemoteFileWatcher.on('uploaded', function (objFile) {
    
        console.log('FILE UPLOADED:');
        console.log(objFile);
    });
    
    objRemoteFileWatcher.on('deleted', function (objFile) {
    
        console.log('FILE DELETED:');
        console.log(objFile);
    });
    
    objRemoteFileWatcher.on('error', function (strServername, error) {
        
            console.log('ERROR: ' + strServername);
            console.log(error);
        });

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i remote-file-watcher

    Weekly Downloads

    21

    Version

    1.0.6

    License

    Apache-2.0

    Last publish

    Collaborators

    • kondor_ltd