react-native-fs icon indicating copy to clipboard operation
react-native-fs copied to clipboard

[Error: ENOENT: : open failed: ENOENT (No such file or directory), open 'undefined']

Open ravis-farooq opened this issue 2 years ago • 3 comments

I am trying to convert pdf file to Base64 but it is showing me [Error: ENOENT: : open failed: ENOENT (No such file or directory), open 'undefined']. I have attached my piece of code where i use react native document picker.

const handleAddDocument = async () => {
  try {
    setFileLoading(true);
    const file = await DocumentPicker.pick({readContent: true});
    file.doc_type = selectedItem[0]; //this is in current state
    const base64 = await RNFS.readFile(decodeURI(file?.uri), 'base64'); //PROBLEM ARISE HERE
     file.base64 = base64;
    const url = await uploadAsset([{name: file.name, file: base64}]);
    file.file = url[0];
    setDocuments((o) => [...o, file]);
  } catch (err) {
    if (DocumentPicker.isCancel(err)) {
    }
    console.log(err);
  } finally {
    setFileLoading(false);
    fileUploadSheet.current?.close();
  }
};

Any help will be appreciated. Thanking you in anticipation.

ravis-farooq avatar Oct 13 '22 09:10 ravis-farooq

@ravis-farooq have you found a solution? I am experiencing the same issue

dmsierra11 avatar Mar 28 '23 07:03 dmsierra11

i have same issue, do u find any solution? I think it gives such an error because it contains special characters.

e.g: Türkçe karaklerler içeriyor.pdf

ahmetcangurel avatar May 01 '23 20:05 ahmetcangurel

same issue here

Pedrohocastro avatar Jul 31 '23 14:07 Pedrohocastro