steelbrain / node-ssh

SSH2 with Promises
MIT License
947 stars 94 forks source link

Is it possible to set transfer mode (binary or ascii) when calling `putFile` #473

Open marin-masic opened 1 year ago

marin-masic commented 1 year ago

Hello. We are uploading XML file (around 2 MB) via FTP using putFile method, and sometimes XML file is malformed after upload. That kind of issue can happen when using ASCII transfer mode for non-ASCII files. Is it possible to set transfer mode when calling putFile? Thank you!

cprkv commented 1 month ago

I have same problem but when uploading big binary file (90 mb). After uploading I check md5 sum and every upload it is different. I changed transfer options to this dirty hack:

const chunkSize = 256 * 1024 * 1024;
const transferOptions = {
  chunkSize,
  step: (_total: number, nb: number, fsize: number): void => {
    if (fsize > chunkSize) {
      throw new Error(`file is too big: ${fsize}. Please increase chunk size`);
    }
  },
};

...

await con.putDirectory(buildDir, "/home/k/traktor", { transferOptions });

And now everything works as expected. It seems like chunked transfer is not working correctly. So this dirty hack disables it.