rn-fetch-blob
rn-fetch-blob copied to clipboard
Crash when downloading large file, even when downloading directly to file
Not sure if this is a bug or if I'm doing something wrong but I'm getting the following crash when downloading a large file (96MB)
04-30 12:00:18.972 13006 13059 E AndroidRuntime: FATAL EXCEPTION: pool-1-thread-1
04-30 12:00:18.972 13006 13059 E AndroidRuntime: Process: net.cozic.joplin, PID: 13006
04-30 12:00:18.972 13006 13059 E AndroidRuntime: java.lang.OutOfMemoryError: Failed to allocate a 257944612 byte allocation with 4190304 free bytes and 160MB until OOM
04-30 12:00:18.972 13006 13059 E AndroidRuntime: at java.lang.StringFactory.newStringFromBytes(StringFactory.java:185)
04-30 12:00:18.972 13006 13059 E AndroidRuntime: at java.lang.StringFactory.newStringFromBytes(StringFactory.java:63)
04-30 12:00:18.972 13006 13059 E AndroidRuntime: at android.util.Base64.encodeToString(Base64.java:456)
04-30 12:00:18.972 13006 13059 E AndroidRuntime: at com.RNFetchBlob.RNFetchBlobFS.readFile(RNFetchBlobFS.java:174)
04-30 12:00:18.972 13006 13059 E AndroidRuntime: at com.RNFetchBlob.RNFetchBlob$6.run(RNFetchBlob.java:208)
04-30 12:00:18.972 13006 13059 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
04-30 12:00:18.972 13006 13059 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
04-30 12:00:18.972 13006 13059 E AndroidRuntime: at java.lang.Thread.run(Thread.java:761)
04-30 12:00:18.975 1705 3755 W ActivityManager: Force finishing activity net.cozic.joplin/.MainActivity
It seems to crash on Base64 decoding which appears to be expected, however I'm setting the config so that it downloads directly to a file, so my understanding is that base64 decoding should not happen:
return RNFetchBlob.config({
path: localFilePath
}).fetch(method, url, headers);
Any idea what am I might be doing wrong or how to avoid this crash?
I'm using fetch-blob 0.10.6 and RN 0.49.
I have also tried using the fileCache: true
property. In this case it does not crash, however when I try to move the file to its final location I get the error:
/data/user/0/net.cozic.joplin/files/RNFetchBlobTmp_9nirk2hsaglipqaokxych (No such file or directory)
If I go to this directory using adb shell
it says "permission denied" as I'm not root but I assume the file has been created, except it somehow cannot be accessed.
Any suggestion on how to solve this? Basically what is the correct way to download a large file to a specific location?
the same issue...
same problem here
Same here
Same problem
Same problem