Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File size is different after upload ! #260

Open
uchar opened this issue Dec 1, 2024 · 3 comments
Open

File size is different after upload ! #260

uchar opened this issue Dec 1, 2024 · 3 comments

Comments

@uchar
Copy link

uchar commented Dec 1, 2024

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 :
image

on local device :
image

Can not open the file after download :
image

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

@uchar
Copy link
Author

uchar commented Dec 1, 2024

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:
image

@razafinarivohanania
Copy link

razafinarivohanania commented Jan 22, 2025

I have the same issue or a similar issue, when it uploads file some bytes disapears.

@razafinarivohanania
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants