Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
williams-voon opened this issue Jul 15, 2018 · 12 comments

Comments

@williams-voon
Copy link

williams-voon commented Jul 15, 2018

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.

@jiangbo0216
Copy link

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

@haotangio
Copy link

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

@jiangbo0216
Copy link

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

@vysotsky
Copy link

Yes, also having this issue. However it cannot be reproduced on 2.9.
Seems like #480 has broken something.

@yuvaraj119
Copy link

yuvaraj119 commented Jul 25, 2018

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

@BruceSuperProgramer
Copy link

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.

@canyara
Copy link

canyara commented Apr 25, 2019

same on 2.10.14, any solution?

@encubos
Copy link

encubos commented May 5, 2020

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

@arthedza
Copy link

Are any updates on this?

@matteodanelli
Copy link

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

@afilp
Copy link

afilp commented Jan 28, 2022

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

@flyskywhy
Copy link

rn-fetch-blob works for me, ref to #756 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests