react-native-fs
react-native-fs copied to clipboard
Content URI directory support
When I pick a single file, it works fine:
const res = await DocumentPicker.pick();
const content = await fs.readFile(res[0].uri);
// good
When I pick a directory, it does not work:
const res = await DocumentPicker.pickDirectory();
const dirs = await fs.readDir(decodeURIComponent(res.uri)); // decode the uri or it will throw a unsupported error
// not worked, throw a error: Permission Denial...ACTION_OPEN_DOCUMENT...
I see the same problem in this PR, but I don't konw how to do.
Environments:
Android 8.0
[email protected]
[email protected]
[email protected]
same problem
Also test RNFS.stat
with file and directory:
const result = await RNFS.stat(file);
console.log(result);
// Error: File does not exist
const result = await RNFS.stat(dir)
console.log(result);
// Error: Unsupported Uri content://com.android.externalstorage.documents/tree/primary%3A...
now I am wondering why readFile
is work.
in another issue #756
env:
Android 12
"react": "17.0.2",
"react-native": "0.67.2",
"react-native-document-picker": "^8.0.0",
"react-native-fs": "^2.19.0"
rn-fetch-blob
works for me, ref to https://github.com/itinance/react-native-fs/issues/756#issuecomment-554937928