react-native-fs icon indicating copy to clipboard operation
react-native-fs copied to clipboard

RNFS.stat reports file not exists, but RNFS.exists reports file exists.

Open williams-voon opened this issue 7 years ago • 12 comments

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.

williams-voon avatar Jul 15 '18 14:07 williams-voon

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

jiangbo0216 avatar Jul 19 '18 06:07 jiangbo0216

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

haotangio avatar Jul 19 '18 06:07 haotangio

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);

jiangbo0216 avatar Jul 19 '18 08:07 jiangbo0216

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.

vysotsky avatar Jul 19 '18 13:07 vysotsky

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

yuvaraj119 avatar Jul 25 '18 15:07 yuvaraj119

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.

BruceSuperProgramer avatar Jan 24 '19 06:01 BruceSuperProgramer

same on 2.10.14, any solution?

canyara avatar Apr 25 '19 07:04 canyara

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

encubos avatar May 05 '20 03:05 encubos

Are any updates on this?

arthedza avatar Jun 11 '20 13:06 arthedza

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

matteodanelli avatar Jul 01 '20 09:07 matteodanelli

Is this bug fixed? I have the same problem, thanks!

afilp avatar Jan 28 '22 10:01 afilp

rn-fetch-blob works for me, ref to https://github.com/itinance/react-native-fs/issues/756#issuecomment-554937928

flyskywhy avatar Mar 22 '22 06:03 flyskywhy