react-native-fs
react-native-fs copied to clipboard
[Error: ENOENT: : open failed: ENOENT (No such file or directory), open 'undefined']
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 have you found a solution? I am experiencing the same issue
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
same issue here