react-native-fs
react-native-fs copied to clipboard
Using react-native-fs for downloading a mp3 or png files, is very slow.
` const downloadImage = async () => { setLoading(true); console.log(startsurah.mp3); await RNFS.downloadFile({ discretionary: true, progress: (res: DownloadProgressCallbackResult) => { console.log("Response written ==="); let progressPercent = (res.bytesWritten / res.contentLength) * 1; // to calculate in percentage console.log("progress===", progressPercent); setProgress({progress: progressPercent.toFixed(2)}); // downloadFileProgress = progressPercent; console.log(res); }, fromUrl: startsurah.mp3,
toFile: `/sdcard/Android/data/com.aljazeera/files/auds/${startsurah.title}.mp3`,
}).promise.then(r => {
console.log(RNFS.DocumentDirectoryPath);
});
setLoading(false);
ShowToast("Surah Downloaded Successfully");
setProgress(0);
};`