1

I pick a file via DocumentPicker, get the URI, and pass it to a function which should open my Document (csv). But i get the Error ENSCOCOAERRORDOMAIN260.
Also i tried to see if there's an file -nope. But i just selected it via DocumentPicker (i get Filename, size, etc via it)

That would be the function:

async readCSVsaveTOJson(uri){
    var RNFS = require('react-native-fs');

    //console.log(RNFS.TemporaryDirectoryPath);
    realDoc = uri.replace('file:/',  '');
    console.log(realDoc);
    var kacke = '';
    var counter = 0;
    for(var i in realDoc){
        if(counter > 0){
            kacke += realDoc[i];
        }
        counter++;
    }

    console.log('exists?');
    console.log(RNFS.exists(kacke));

    RNFS.readDir(kacke')
      .then((result) => {
          // stat the first file
          console.log('result');
          return Promise.all([RNFS.stat(result[0].path), result[0].path]);
      })
      .then((statResult) => {
          if (statResult[1].isFile()) {
              // if we have a file, read it
              var content = RNFS.readFile(kacke);
              console.log('--------------------------');
              console.log(content);
              return RNFS.readFile(statResult[1], 'utf8');
          }

          return 'no file';
      })
      .then((contents) => {
          // log the file contents
          console.log(contents);
      })
      .catch((err) => {
          console.log('ERROR, theres is nothing');
          console.log(err.message, err.code);
      });
}

it throws console.log('ERROR, theres is nothing');.. buut i know there should be something.

Any recommandings?
Huge Thanks

Kirill Novikov
  • 2,576
  • 4
  • 20
  • 33
Flo Sojer
  • 81
  • 8

0 Answers0