1

I tried to get Data of the Document but I only get Null.
Documentpicker is working, except: The Selected Data is NULL.

async openDocumentReader() {
    try {
        const res = await DocumentPicker.pick({
            type: [DocumentPicker.types.csv],
        });
        console.log(
          res.uri,
          res.type,
          res.name,
          res.size,
        );
        if (res.name == null) {
            Alert.alert('Document is Null');
        }
    } catch (err) {
        if (DocumentPicker.isCancel(err)) {
            //User canceld
        } else {
            throw err;
        }
    }

Any recommendations?

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

1 Answers1

-1

I found a solution: I had to choose pickSingle for it.

try {
    const res = await DocumentPicker.pickSingle({
        type: [DocumentPicker.types.csv], mode : 'import', copyTo: 'documentDirectory',
    });
    var uri = res.uri;
    var name = res.name;
    var fileCopyUri = res.fileCopyUri;
    console.log(JSON.stringify(res));
    console.log(res.uri); 
}

Or something like that.

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