Rn-fetch-blob: iOS : Error with stat with path returned by RNDocumentPicker

Created on 28 Nov 2019  ·  5Comments  ·  Source: joltup/rn-fetch-blob

I'm having trouble with stat on iOS:

Error: failed to stat pathfile:///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.csvbecause 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.

Most helpful comment

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

All 5 comments

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

I'm facing the same issue on both ,Android and iOS.Could you please help ?

For Android, you have to use the following package to get the real file name :

"react-native-get-real-path": "git+https://github.com/Wraptime/react-native-get-real-path.git"

Thanks .and for iOS?

I have no idea other than my proposed workaround above.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wamry picture wamry  ·  16Comments

fa16mscs0004 picture fa16mscs0004  ·  13Comments

learnyst picture learnyst  ·  27Comments

alpha0010 picture alpha0010  ·  20Comments

TheWirv picture TheWirv  ·  13Comments