Error: Invalid Filesystem URI


#1

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

#2

Hey, I’m experiencing the same issue. It seems like there’s something wrong with the path that’s generated for android. Not sure how to approach it but I know it occurs for more than just downloading.

simple example that produces the same error on android but works on iOS:

async componentWillMount () {
    try {
      let documentDirectory = await FileSystem.readDirectoryAsync(FileSystem.documentDirectory)
      console.log('document: ', documentDirectory)
    } catch (err) {
      console.error(err)
    }
  }

#3

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()
})