I am trying to download some files using SFTP in Node. I know I have to handle the stream but I am not sure how I should do this and save the file in my local machine (in the downloads folder).
app.get('/download', (req, res) => {
var Client = require('ssh2-sftp-client');
var sftp = new Client();
var config = {
host: 'host123',
port: '22',
username: 'username',
password: 'secretpassword'
};
sftp.connect(config).then((data) => {
res.download(data);
});
});
Thanks!