Skip to content

Android: Proper way to download a file for user media consumption #380

Open
@PaperbagWriter

Description

@PaperbagWriter

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 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions