sergi/jsftp

ftp.get() not working correctly

alimsahy opened this issue · 7 comments

When I try to download the file with the get method, it downloads the file but the file appears to be 0 kb. Is there something I did wrong?

function downloadUpdates()
{
        return new Promise((resolve, reject) =>
            {
                if (filesToUpdate.length > 0)
                {
                    filesToUpdate.forEach(file =>
                    {
                        var fileName = file.split('/').pop();
                        var filePath = file.replace(fileName, '');
                        var localPath = application.getAppPath() + '/files' + file.replace(ftpPath, '');
                        
                        console.log(fileName);
                        console.log('Download Destination: ' + localPath);
                        console.log('Remote location: ' + file);

                        ftp.get(file, localPath, (err) =>
                        {
                            console.log('Downloading..');
                        });
                    });
                    resolve(true);
                }
                else
                {
                    reject(false);
                }
            });
        }

Result:
image

i have the same issue, download file get 0 KB. it's work fine on Node version 9.0.5

same issue after upgrade node from V8.15.1 to V12.11.1 and got errno: 'ECONNRESET'

same issue after upgrade node from v9 to v10

So after all. I am using basic-ftp. It works well. recommend to others if have the same problem but still want to use a similar ftp package.

Any update on this issue @sergi?

Thanks @JonathanChaochen i tried basic-ftp and it works. Don't recommend using this lib. Those weird issues wasted me a lot of time

For who want to work with sftp, you can use this package, easy to use:

https://www.npmjs.com/package/mysftp