I want to download a file in React Native and save it in a Directory selected by the User (e.g. Downloads).
Right now I'm using https://www.npmjs.com/package/react-native-document-picker to let the user pick a directory and https://www.npmjs.com/package/react-native-fs/v/1.2.0 to download the file.
Unfortunately, react-native-document-picker only gives me a dynamic URI to the directory, which does not exist when react-native-fs tries to access it. I think it's hidden behind something like a File-Provider.
I searched a lot but found no solution on how to get the real static path to a directory. Might be that I am missing something obvious, but I can not figure it out right now.
the code (simplified)
DocumentPicker.pickDirectory().then(pick => {
// this looks something like:
// file:///private/var/mobile/Containers/Shared/AppGroup/8443...EC/File%20Provider%20Storage/Downloads/
const pickedDirectory = pick.uri;
// resolves to false:
RNFS.exists(pickedDirectory)
// does not work
RNFS.downloadFile({
fromUrl: downloadUrl,
toFile: pickedDirectory + filename,
}).promise.then(r => { console.log(r)
});