Hello, i'm trying download a file using:
FileSystem.createDownloadResumable("http://remote-uri.com", `${FileSystem.documentDirectory}my_file.ext`)
In IOS it works very well, but in android i got this error:
Invalid Filesystem URI 'file:///data/user/0/host.exp.exponent/files/ExperienceData/%2540my_user%252Fmy-react-native-app/my_file.ext', make sure it's in the app's scope.
What can i do?
Environment:
"expo": "^20.0.0",
"react": "16.0.0-alpha.12",
"react-native": "https://github.com/expo/react-native/archive/sdk-20.0.0.tar.gz",
Any update here? From my debugging it seems like on android, you can access child directories of documentDirectory and cacheDirectory, but not either directory itself.
Example:
FileSystem.readDirectoryAsync(FileSystem.documentDirectory) // fails with 'invalid uri'
FileSystem.readDirectoryAsync(FileSystem.documentDirectory + 'cats/') // success
I have a discussion here too
I found a solution. I create a folder inside document directory and after it works well.
ensureFolderExists () {
const path = `${FileSystem.documentDirectory}MyFolder`
return FileSystem.getInfoAsync(path).then(({exists}) => {
if (!exists) {
return FileSystem.makeDirectoryAsync(path)
} else {
return Promise.resolve(true)
}
})
}
ensureFolderExists().then(() => {
FileSystem.createDownloadResumable("http://remote-uri.com", `${FileSystem.documentDirectory}MyFolder/my_file.ext`).downloadAsync()
})
I just tested this at the root and it works, and I think this may be related to https://github.com/expo/expo/issues/739 so closing for now. Please comment if you face this again!
Most helpful comment
I have a discussion here too
I found a solution. I create a folder inside document directory and after it works well.