Skip to content

Instantly share code, notes, and snippets.

@BorePlusPlus
Last active September 23, 2016 16:44
Show Gist options
  • Save BorePlusPlus/c9186c8feb9902f84da3e35f313a43a8 to your computer and use it in GitHub Desktop.
Save BorePlusPlus/c9186c8feb9902f84da3e35f313a43a8 to your computer and use it in GitHub Desktop.
Missing bytes
Client :: ready
Stat: Stats {
mode: 33206,
permissions: 33206,
uid: undefined,
gid: undefined,
size: 1172943,
atime: 1473984262,
mtime: 1473984262 }
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 32768 thisPool.length: 32768
bytesRead: 26063 thisPool.length: 32768
bytesRead: 0 thisPool.length: 32768
buffer.length 1172943
Client :: ready
Stat: Stats {
mode: 33206,
permissions: 33206,
uid: undefined,
gid: undefined,
size: 1172943,
atime: 1473984262,
mtime: 1473984262 }
bytesRead: 65535 thisPool.length: 65536
bytesRead: 65535 thisPool.length: 65536
bytesRead: 65535 thisPool.length: 65536
bytesRead: 65535 thisPool.length: 65536
bytesRead: 65535 thisPool.length: 65536
bytesRead: 65535 thisPool.length: 65536
bytesRead: 65535 thisPool.length: 65536
bytesRead: 65535 thisPool.length: 65536
bytesRead: 65535 thisPool.length: 65536
bytesRead: 65535 thisPool.length: 65536
bytesRead: 65535 thisPool.length: 65536
bytesRead: 65535 thisPool.length: 65536
bytesRead: 65535 thisPool.length: 65536
bytesRead: 65535 thisPool.length: 65536
bytesRead: 65535 thisPool.length: 65536
bytesRead: 65535 thisPool.length: 65536
bytesRead: 65535 thisPool.length: 65536
bytesRead: 58831 thisPool.length: 65536
bytesRead: 0 thisPool.length: 65536
buffer.length 1172926
var fs = require('fs');
var Client = require('ssh2').Client;
var conn = new Client();
conn.on('ready', function() {
console.log('Client :: ready');
conn.sftp(function(err, sftp) {
if (err) throw err;
sftp.stat('directory/file.zip', function (err, stat) {
if (err) throw err;
console.log('Stat:', stat);
});
// BEFORE
// var stream = sftp.createReadStream('directory/file.zip', {});
// AFTER
var stream = sftp.createReadStream('directory/file.zip', { highWaterMark: 32 * 1024 });
var chunks = [];
stream.on('data', function(chunk) {
chunks.push(chunk);
});
stream.on('end', function () {
var buf = Buffer.concat(chunks);
console.log('buffer.length', buf.length);
conn.end();
});
});
}).connect({
host: 'somewhere.example.com',
port: 22,
username: 'foo',
password: 'bar'
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment