File size is different after upload !
Describe the bug
Just a basic file upload compelte with no error but the file size is different after upload and the file is corrupt.
on server :
on local device :
Can not open the file after download :
Example code
import { Client } from 'basic-ftp';
const main = async (): Promise<void> => {
const ftpClient = new Client(900000);
await ftpClient.access({
host: '....',
user: '...',
password: '....',
});
ftpClient.trackProgress((info) => {
console.log('Transferred', info.bytes, info.bytesOverall);
});
ftpClient.ftp.verbose = true;
await ftpClient.uploadFrom('backups/1.zip', '1.zip');
ftpClient.close();
};
main()
.then(() => {
console.log('Completed successfully.');
process.exit(0);
})
.catch((error) => {
console.error('An error occurred:', error);
process.exit(1);
});
Console output From the log you can see somehow it immediatel jump to 1245184 but the thing is every time I run the code the output size is different
> ts-node src/test.ts
Trying to find optimal transfer strategy...
> EPSV
< 229 Entering Extended Passive Mode (|||35578|)
Optimal transfer strategy found.
> STOR 1.zip
< 150 Opening BINARY mode data connection for 1.zip
Uploading to ip:35578 (No encryption)
Transferred 0 0
Transferred 1245184 1245184
Transferred 1310720 1310720
Transferred 1310720 1310720
Transferred 1310720 1310720
Transferred 1310720 1310720
Transferred 1310720 1310720
Transferred 1310720 1310720
Transferred 1310720 1310720
Transferred 1310720 1310720
Transferred 1310720 1310720
Transferred 1507328 1507328
Transferred 1507328 1507328
Transferred 1507328 1507328
Transferred 1507328 1507328
Transferred 1507328 1507328
Transferred 1507328 1507328
Transferred 1638400 1638400
Transferred 1638400 1638400
Transferred 1638400 1638400
Transferred 1703936 1703936
Transferred 1703936 1703936
Transferred 1769472 1769472
Transferred 1835008 1835008
Transferred 1900544 1900544
Transferred 1900544 1900544
Transferred 1900544 1900544
Transferred 1989694 1989694
Transferred 1989694 1989694
< 226 Transfer complete
> QUIT
Completed successfully.
Which version of Node.js are you using? Node : v22.11.0
Which version of basic-ftp are you using? 5.0.5
Additional context Running in windows
Just created another file with 2mb of predictable content like :
1234567890(1)
1234567890(2)
1234567890(3)
...
Upload it again. The sequence is fine from 1 to 63,594, but there is no data afterward (it should upload until 116,224). So, half of the file seems unwritten. I don’t understand why this code doesn’t throw some sort of error if it’s unable to upload the file completely. Maybe a simple check can be added to compare the file size and the data written. At the very least, it should throw a more meaningful message instead of silently stating that the data transfer is finished when it’s not.
output of file on the server:
I have the same issue or a similar issue, when it uploads file some bytes disapears.
Finally, the mine was not an issue, it is an issue from Filezilla, it treats my file as text. After suffixing extension by .bin it is not corrupt anymore.