Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: RNBackgroundDownloader.directories.documents returns invalid directory path on Android #10

Open
mtshv opened this issue Mar 27, 2024 · 4 comments

Comments

@mtshv
Copy link

mtshv commented Mar 27, 2024

Hi there,

I've encountered an issue with RNBackgroundDownloader.directories.documents on Android:

  • When logging RNBackgroundDownloader.directories.documents, I get /storage/emulated/0/Android/data/<package_identifier>/files.
  • However, when trying to get directory info using await FileSystem.getInfoAsync(RNBackgroundDownloader.directories.documents), I receive {"exists": false, "isDirectory": false}.
  • In contrast, logging FileSystem.documentDirectory returns file:///data/user/0/<package_identifier>/files/, and this directory does exist.
  • Is this behavior known or expected, or am I missing something?

On iOS, the output of both RNBackgroundDownloader.directories.documents and FileSystem.documentDirectory are identical.

Does this mean that we cannot rely on RNBackgroundDownloader.directories.documents on Android?

Any insights or suggestions would be greatly appreciated.

Thank you!

@vSyrotkinRelevant
Copy link

Hey there,
Have you found the correct path for that?
Pls tell me how you managed that issue.

@mtshv
Copy link
Author

mtshv commented May 2, 2024

@vSyrotkinRelevant for now, I am using

import * as FileSystem from 'expo-file-system';
const downloadPath = FileSystem.documentDirectory

As this approach returns the existing directory for both ios and android, I think you can achieve the same with other filesystem libraries for React Native.

I haven't tested this extensively yet, so I can't guarantee that it's the ultimate solution. But this is what I have for the moment

P.S. Still very curious about the RNBackgroundDownloader.directories.documents issue that I am seeing. And wonder what users of this package are using for download directories on Android. Perhaps @kesha-antonov could shed some light

@MickaelNeves
Copy link

Yap bumped into the same exact issue, iOS works great with RNBackgroundDownloader.directories.documents but not in Android, so ended up using FileSystem.documentDirectory for both.

@jacksonsmith
Copy link

Is there any solution already mapped for this to contribute, or should we each handle this scenario on our own ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants