node-ftp icon indicating copy to clipboard operation
node-ftp copied to clipboard

Binary Image Gets Corrupted When PUT Over FTP

Open agilliam-cmg opened this issue 5 years ago • 2 comments

Every image I PUT() to a server using FTP client gets corrupted. I've tested with jpeg and png, all are damaged during transfer. Some characters are missing and some are displaced:

async sendImage(image) { try { const credentials = await getFtpCredentials(this.platform); console.log('Sending files via FTP client'); return new Promise((resolve, reject) => { let ftpClient = new ftp(); ftpClient.on('ready', () => { console.log(Putting ${image.path} onto server); // Set transfer type to binary ftpClient.binary(err => { if(err) reject(err); else // image.content is binary string data ftpClient.put(image.content, image.path, (err) => { if (err) { reject(err); } console.log('Closing FTP connection'); ftpClient.end(); resolve(FTP PUT for ${image.path} successful!`); });

                });
            });
            console.log('Connecting to FTP server');
            ftpClient.connect(credentials);
        });

` Here's a copy of the image before sending over FTP and here's a corrupted copy after. Please compare the two using a binary editor or regular notepad. I hope this issue can be resolved as I like this library!

Thanks!

agilliam-cmg avatar Aug 22 '19 21:08 agilliam-cmg

Have you found a workaround?

besserwisser avatar Sep 07 '19 21:09 besserwisser

@besserwisser No, I'm using the basic-ftp library instead.

agilliam-cmg avatar Sep 09 '19 17:09 agilliam-cmg