Nauseating Pumpkin Mush

    simple-sftp

    0.1.0 • Public • Published

    simple-sftp

    Dirt-simple, callback-based, easy-to-use SFTP via ssh2. Downloads and uploads are done via readable and writable streams respectively.

    The built-in SFTP capabilities of ssh2 were giving me trouble when connecting to SpringCM via SFTP, and I found that I had to get down to brass tacks and do file open, buffered read, file close. That's exactly what this library does. No crazy multiple reader solutions, nothing fancy: open the file, read it until there's nothing left to read, then close it.

    Download a file

    const SFTP = require('simple-sftp');
     
    var client = new SFTP();
     
    client.connect({
        hostname: 'sftp.website.com',
        username: 'user@website.com',
        keyfile: 'C:\\Path\\To\\Key\\Here',
        password: 'or_your_password'
    }, (err) => {
        if (err) {
            return console.log(err);
        }
     
        client.get('/path/to/file.txt', (err, stream) => {
            if (err) {
                return console.log(err);
            }
     
            // Do what you will, e.g. write to a file
            stream.pipe(fs.createWriteStream('./file.txt'));
            stream.on('end', () => {
                client.disconnect();
                process.exit(0);
            });
        });
    });

    Install

    npm i simple-sftp

    DownloadsWeekly Downloads

    0

    Version

    0.1.0

    License

    MIT

    Last publish

    Collaborators

    • paulholden