0

I am using ssh2-sftp-client to connect to an sftp server and download files. I know the connection is working as I can download the files but I am getting 0 byte zip files.

this._connection is a ssh2-sftp-client object. file is the name of the file.

async download(_sourcePath: String, _basePath: String, file: String): Promise<void> {
    await this._connection.get(_sourcePath + '/' + file, _basePath + '/' + file)
}

Above is the code I am using. The files are getting dropped off but they are 0 bytes. Not sure what I am doing wrong here. I am using await expecting the promise to be fufilled.

When I try this code outside of my project with this code it works:

sftp.connect(options)
.then(() => {
 return sftp.list('/some path')
})
.then(data => {
 console.log(data)
for (let i = 0; i < data.length; i++) {
 sftp.get(_sourcePath + '/' + data[i]['name'], _basePath + '/' + data[i]['name'])}
}).catch(err => {
 console.error(err.message);
});
foxRun28
  • 13
  • 4

0 Answers0