wkh237 / react-native-fetch-blob

A project committed to making file access and data transfer easier, efficient for React Native developers.
MIT License
2.61k stars 1.59k forks source link

access content://com.android.providers.media.documents/document/image%3A99 #536

Open EyalSi opened 7 years ago

EyalSi commented 7 years ago

I'm getting a content:// uri in android while using react-native-document-picker or react-native-contacts (for the avatars). URIs like: 'content://com.android.providers.media.documents/document/image%3A99' Trying to access this file fails with "stat error: failed to list path null for it is not exist or it is not a folder'"

const urlDecoded = decodeURIComponent(url); return new Promise((resolve, reject) => { RNFetchBlob.fs.stat(urlDecoded) .then(resolve) .catch(reject); });

Any idea how to access the file? 10x

tombailey commented 7 years ago

You should take a look at my PR (https://github.com/wkh237/react-native-fetch-blob/pull/546) although I haven't touch the FS part of this library.

The current implementation in this library for content URIs on Android seems to try to find the file path for a given content URIs. If the file is a virtual file or in a place your app doesn't have access to, this is problematic.

EyalSi commented 6 years ago

There is now a solution for this problem in react-native-fs. Enabling access and copy content:// files -https://github.com/itinance/react-native-fs/pull/395

anarchytech commented 5 years ago

Good