Implemented download functionality using the fetch method, which is available in react-native-file-access
Note:
Opted for react-native-file-access over react-native-blob-util due to issues with async/await inside the onData method in react-native-blob-util, which required some workarounds. The implementation with react-native-file-access was more straightforward.
I've added properties mentioned below to Info.plist, as without them we had only access to downloaded files within the app storage. When those properties are added it allows the system Files app to display the content of the app's internal storage. The downside of this solution is that if the app's storage is cleared (for example app is removed) it will also clear the downloaded files. The only other way was to use react-native-share or a similar solution that would show the bottom sheet with a possibility to save the file to external storage (Files in this case) and then we would also need to remove the file from internal app's storage. I think it's worth to mention that in the documentation/readme.
Summary
fetch
method, which is available inreact-native-file-access
Note:
react-native-file-access
overreact-native-blob-util
due to issues withasync/await
inside theonData
method inreact-native-blob-util
, which required some workarounds. The implementation withreact-native-file-access
was more straightforward.Info.plist
, as without them we had only access to downloaded files within the app storage. When those properties are added it allows the systemFiles
app to display the content of the app's internal storage. The downside of this solution is that if the app's storage is cleared (for example app is removed) it will also clear the downloaded files. The only other way was to use react-native-share or a similar solution that would show the bottom sheet with a possibility to save the file to external storage (Files
in this case) and then we would also need to remove the file from internal app's storage. I think it's worth to mention that in the documentation/readme.Here are some GitHub issues related to the above (it's in
react-native-blob-util
repo, but it's same for other File System libraries): https://github.com/RonRadtke/react-native-blob-util/issues/62#issuecomment-1024041198 https://github.com/RonRadtke/react-native-blob-util/issues/161#issuecomment-1163861822Demo
https://github.com/user-attachments/assets/68e63cc3-0c6a-4f78-b980-e82e3432053e
Closes: OMHD-470