itinance / itinance/react-native-fs
[Error: ENOENT: : open failed: ENOENT (No such file or directory), open 'undefined']
- Dominant language
- C++
- Stars
- 5k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.