React-native-fs: RNFS.stat reports file not exists, but RNFS.exists reports file exists.

Created on 15 Jul 2018  路  10Comments  路  Source: itinance/react-native-fs

The code that call RNFS.stat (version 2.9.11) works.

But after I upgrade RNFS to the latest version, and RNFS.stat always run into exception, says file does not exists.

My sample code:

let path='file:///data/user/0/com.fzbdemo8/cache/1531620707190.JPEG'
RNFS.stat(path).then(
(stat)=>{}
).catch((err) => {
        console.log(err.message, err.code); //run into exception
      });

The file do exists.

Most helpful comment

same on 2.10.14, any solution?

All 10 comments

I meet this problem too,please help .how to fix it

I'm having this problem too. Can someone help?

I check the code,and then add this line File file = new File(filepath);

      String originalFilepath = getOriginalFilepath(filepath);
      // File file = new File(originalFilepath);
      File file = new File(filepath);
      if (!file.exists()) throw new Exception("File does not exist");

      WritableMap statMap = Arguments.createMap();

then I got this result
{path: "/storage/emulated/0/Android/data/*****", ctime: Thu Jul 19 2018 14:17:05 GMT+0800 (涓浗鏍囧噯鏃堕棿), mtime: Thu Jul 19 2018 14:17:05 GMT+0800 (涓浗鏍囧噯鏃堕棿), size: 430392, mode: undefined,聽鈥
I think there is some wrong with this line
File file = new File(originalFilepath);

Yes, also having this issue. However it cannot be reproduced on 2.9.
Seems like https://github.com/itinance/react-native-fs/pull/480 has broken something.

Any fixes or update on this issue.
For file:// its working but for file:/// its not working

Your URL in your path may contains chinese. I solved it by following code:
let filePath = decodeURIComponent(res.uri);

I used react-native-document-picker.
Returned uri(file path) contains Chinese characters.

same on 2.10.14, any solution?

Same issue here, I can't get the real path from a URI
Running Android
react-native-fs -- version: "2.16.6"

Error: File does not exist

my URI es like:
content://com.android.providers.downloads.documents/document/15

Are any updates on this?

Same error of @encubos. Any solution or workaround to resolve real path from URI?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JohnRyanTsai picture JohnRyanTsai  路  3Comments

duckmyanmar picture duckmyanmar  路  3Comments

opoze picture opoze  路  3Comments

MuppaAkhil picture MuppaAkhil  路  3Comments

let-aurn picture let-aurn  路  3Comments