kathawala / expo-file-dl

Download files to any folder and notify the user while the download is happening and when the download finishes
MIT License
44 stars 8 forks source link

Can we get download progress feature #11

Closed EndLess728 closed 3 years ago

EndLess728 commented 3 years ago

I need to show download progress in percentage so I need download progress feature to achieve it.

PS: Library is awesome working like charm.

kathawala commented 3 years ago

Thanks for the suggestion @EndLess728. This was added in the latest release (2.0.0). You can get it from npm right now.

So if before you were calling downloadToFolder as follows:

await downloadToFolder(uri, filename, folder, channelId);

you can now call it with the following callback and you will get back the progress information you want:

const downloadProgressCallback = ({totalBytesWritten, totalBytesExpectedToWrite}) => {
  const pctg = 100 * (totalBytesWritten / totalBytesExpectedToWrite);
  setProgressInfo(`${pctg.toFixed(0)}%`);
};
await downloadToFolder(uri, filename, folder, channelId, {downloadProgressCallback});

Hope this helps!

PeeJeeDR commented 3 years ago

Hi, I have a question related to this issue. Is it possible to show the progress in the Notification? This library is awesome!