qgustavor / mega

Unofficial JavaScript SDK for MEGA
https://mega.js.org/
MIT License
161 stars 43 forks source link

Download not starting no error feedback #112

Closed edu81 closed 2 years ago

edu81 commented 2 years ago

After successful log into Mega and getting the list of files in the cloud, I am using this function to download a given file f:

const downloadFileFromMega = (f) => {
  console.log(`START DOWNLOAD FILE  ${f.name}`);
  const stream = f.download();
  stream.on("error", (error) => console.log(`DOWNLOAD ERROR: ${error}`));
  stream.on("end", () => console.log(`DOWNLOAD DONE`));
  stream.on("data", (c) => console.log(`GOT NEW DATA`));

 console.log(`CREATE PIPE`);
 stream.pipe(fs.createWriteStream(`${getBasePsth()}/${f.name}`));
};

Apparently all works fine, but when testing it on certain machine, nothing happens, I can see the logs for "download file" and "create pipe" and that's it....no download progress but no error either.

Not sure if something is wrong here or if maybe mega is for some reason blocking download from one of my machines IP....however I have checked inside Mega and it does not seem to be blocking anything.

Any suggestion?

edu81 commented 2 years ago

found my mistake myself, thanks!