question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

iOS : Error with stat with path returned by RNDocumentPicker

See original GitHub issue

I’m having trouble with stat on iOS:

Error: failed to stat path file:///private/var/mobile/Containers/Data/Application/75F278D1-A1BB-4E75-8C98-E95FC7DC86E2/tmp/com.sensoriaanalytics.CardioSensys-Inbox/Olivier__50yo_NaNcm_2019_11_24_10h_50m_26s.csv because it does not exist or it is not a folder

With a path returned by RBDocumentPicker on iOS.

I’m using: “react-native-document-picker”: “^3.2.4”, “rn-fetch-blob”: “^0.10.15”,

Here is the code:

DocumentPicker.pick({
          type: [DocumentPicker.types.csv]
        })
          .then(res => {
            var file;
            // if (RX.Platform.getType() === "android") {
            RNFetchBlob.fs.stat(res.uri).then(stats => {
              file = {
                uri: "file://" + stats.path,
                type: res.type,
                name: res.name
              };
              logging.logWithTimestamp(
                `Path [${file.uri}] MimeType [${file.type}] Name [${file.name}] Size [${res.size}]`
              );

I would say that the file path returned by the picker is invalid but this seems strange.

Any help appreciated.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

11reactions
omatrotcommented, Nov 28, 2019

Solved the problem by removing “file:///private” from the beginning of The Uri returned by RNDocumentPicker.

0reactions
omatrotcommented, Jan 3, 2020

I have no idea other than my proposed workaround above.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Path for resource returns nil file path despite file is in ...
I see a nil value for the pathFor variable. However, if I contextually check the file existence in my app Bundle (using XCode...
Read more >
contentsOfDirectoryAtPath:error - Apple Developer
Performs a shallow search of the specified directory and returns the paths of any contained items. iOS 2.0+ iPadOS 2.0+ macOS 10.5+ Mac...
Read more >
react-native-document-picker - Bountysource
On iOS 13 the UIDocumentPickerViewController appears fine, I can navigate through folders OK but when I tap on a particular file nothing happens....
Read more >
Top 5 react-native-fs Code Examples - Snyk
writeFile(path, xmlString, 'utf8'); //using console.log output is not shown in ... stat the first file return Promise.all([RNFS.stat(result[0].path), ...
Read more >
react-native-fs - npm
Start using react-native-fs in your project by running `npm i ... return Promise.all([RNFS.stat(result[0].path), result[0].path]);.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found