Im using the https://www.npmjs.com/package/ssh2-sftp-client library and have the following working code.
async function upload() {
let sftp = new Client();
await sftp.connect(config)
.then(() => {
return sftp.fastPut('test.txt' , 'test.txt');
})
.then(p => {
console.log(`${p}`);
return sftp.end();
})
.catch(err => {
console.log(`Error: ${err.message}`); // error message will include 'example-client'
});
}
upload()
There are two things in the docs that I don't understand.
- This https://www.npmjs.com/package/ssh2-sftp-client#debugging-support suggests that I can add this to my code to enable debug e.g.
config.debug = msg => {
console.error(msg);
};
However, I can't work out where this should go.
- The docs also suggest https://www.npmjs.com/package/ssh2-sftp-client#uploaddirsrcdir-dstdir--string that I can add an event listener to the code to get the events. e.g.
client.on('upload', info => {
console.log(`Listener: Uploaded ${info.source}`);
});
However, again I can't figure where this should go.
Sorry if these dumb questions, but Async coding messes with my brain.