react-native-fs
react-native-fs copied to clipboard
Use react-native-fs download a mp4 file,is very slow
the mp4 is 698K but download it,is very slow,very very slow.
Do you have this question?
same issue... an audio file of few mb takes minutes of time to download.
me too.
Are you running your app in Debug mode or Release?
release
On Fri, Feb 17, 2017 at 8:32 PM, Eric Forkosh [email protected] wrote:
Are you running your app in Debug mode or Release?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/johanneslumpe/react-native-fs/issues/230#issuecomment-280673288, or mute the thread https://github.com/notifications/unsubscribe-auth/AHcOS50TfpAqsgqrdWqv6rCK4EGlW-c0ks5rdbadgaJpZM4LdS4T .
iOS or Android or both?
Under the hood this Lib uses native methods to manage network requests:
iOS: NSUrlSessionDownloadTask Android: HttpUrlConnection
But, on Android the Buffer-Size is very small (8 kb). You might want to increase the buffer-size for testing purposes and make a suggestion if you could speed up the download process then?
Change these both lines for testing with a higher buffer size (maybe 64 kb or more):
- https://github.com/itinance/react-native-fs/blob/master/android/src/main/java/com/rnfs/Downloader.java#L103
- https://github.com/itinance/react-native-fs/blob/master/android/src/main/java/com/rnfs/Downloader.java#L106
Don't forget to restart the packager after modification of native library code and to recompile/reinstall the app then. Let me know if you could speed it up pls.
Hello @itinance, I have the same problem on iOS, how can I solve it?
Thank you, Marco
slow? you setState prograss?
did anyone solve this?
Same problem. rn-fetch-blob has (had, before parallel download broke) much better download performance.
In my case changing the background property from false to true solved the speed issue.
const progress = RNFS.downloadFile({
background: false, // if true, download is going to be very slow on iOS.
begin: file => (contentLength = file.contentLength),
discretionary: true,
fromUrl: url,
progressDivider: 5,
toFile: localUrl,
progress: res => {
let progress = (res.bytesWritten / res.contentLength) * 100
progress = parseInt(progress?.toFixed(2))
console.log(progress)
}
})