React Native get real path of file on Android


This Content is from Stack Overflow. Question asked by rtamz

I’m using react-native-document-picker to select a file and react-native-fs to upload the file.

try {
        const res = await DocumentPicker.pick({
        type: [DocumentPicker.types.allFiles],
        copyToCacheDirectory: false

I’m getting the uri as – content://

Then I’m converting this to actual path using react-native-get-real-path.

        .then(filePath =>{
          realFilePath = filePath
, ToastAndroid.SHORT);

The above method gives the path as /storage/emulated/0/Download/output-onlinepngtools.png but this working for few files, for others I’m getting null as the real-path.

This is working perfectly with the uri alone on iOS and I’m able to upload the file successfully to the server.


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?