You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm confused about what is the best way to download a file on Android on different versions and for this media to be accessible in the Download apps or the Gallery apps. For the regular downloads internally to the app everything I think is pretty straight forward but for the above use case, the doc is very ambiguous.
From the doc I got the impression that from Android version 10 and upwards we should use copyToMediaStore. This works but makes it so that the downloadManager won't point to the file upon completion (downloads to cache then copies), so I need to skip the download manager.
For the versions below 10 we should use a path such as ReactNativeBlobUtil.fs.dirs.LegacyDCIMDir.
My confusion comes from the fact that I'm able to download to ReactNativeBlobUtil.fs.dirs.LegacyDCIMDir without using the copyToMediaStore on all Android versions (9-13). Is there a reason why I should not do that (and it is considered legacy)?
This also avoids having unwanted cached files, downloading directly to the internal storage InternalStorage/DCIM.
The documentation is pretty non-existent for Android below 10 so I wanted to update it, but because of the confusion, I did not.
Thanks
The text was updated successfully, but these errors were encountered:
PaperbagWriter
changed the title
Proper way to download on Android
Android: Proper way to download a file for user media consumption
Aug 28, 2024
It all boils down to what you want your user to do. ReactNativeBlobUtil.fs.dirs.LegacyDCIMDir is private to your app. So it will not show int he users gallery, or downloads for the other paths.
If you want the file to be visible in the gallery / downloads folder, you have to use the media store api on Android > 10.
For Android < 10 you can download the file to the downloaddir, or you use the Android Downloadmanager.
The android downloadmanager can also be used for Android > 10. But the API for it to add files to the downloads folder is deprecated, so unsure how long we can use it.
Versions:
react-native-blob-util: "0.19.11",
react-native: "0.73.9"
I'm confused about what is the best way to download a file on Android on different versions and for this media to be accessible in the Download apps or the Gallery apps. For the regular downloads internally to the app everything I think is pretty straight forward but for the above use case, the doc is very ambiguous.
From the doc I got the impression that from Android version 10 and upwards we should use copyToMediaStore. This works but makes it so that the downloadManager won't point to the file upon completion (downloads to cache then copies), so I need to skip the download manager.
For the versions below 10 we should use a
path
such asReactNativeBlobUtil.fs.dirs.LegacyDCIMDir
.My confusion comes from the fact that I'm able to download to
ReactNativeBlobUtil.fs.dirs.LegacyDCIMDir
without using the copyToMediaStore on all Android versions (9-13). Is there a reason why I should not do that (and it is considered legacy)?This also avoids having unwanted cached files, downloading directly to the internal storage
InternalStorage/DCIM
.The documentation is pretty non-existent for Android below 10 so I wanted to update it, but because of the confusion, I did not.
Thanks
The text was updated successfully, but these errors were encountered: