How can I read the content-URI file in React Native on Android?

I am using React Native (0.48.3) for Android development. I seem to be stuck in a really trivial task: select a file and read it as a string. I have response-native-document-picker v2.0.0 to select a file, and it works fine: I can select the file and get its URI. The problem is that I can not make any package to read the file from this link. I already tried react-native-filesystem and react-native-fs , but it seems that they can only work with files in the application directory. Anyway, I get an error message:

Error: File was not found: content://com.android.providers.downloads.documents/document/7

Which package or feature do I need to use?

UPD: finding the real, not content:// path, with react-native-get-real-path makes everything work. But is this conversion really necessary, is it possible to use the path content:// to upload files?

+7
source share
1 answer

On Android devices, you will need to add the file "file: //" to download any file. You can do this using the package you specified or simply manually. If you add it manually, you can use response-native-fs to respond to the URI.

0
source

Source: https://habr.com/ru/post/1271898/


All Articles