itinance / itinance/react-native-fs
How to get File path from the document directory in iOS and convert that file to Base64.
- Dominant language
- C++
- Stars
- 5k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
Hi Team,
Please help me to get the file path from the document in the iOS and also convert the file to Base64 format.
Please find my below code and also find the screenshots.
*****************************************************************************************************************
async pickupDocuments() {
try {
const results = await DocumentPicker.pickMultiple({
type: [DocumentPicker.types.allFiles],
});
for (const res of results) {
const split = (res.uri).split('/');
const name = split.pop();
const inbox = split.pop();
const realPath = 'file://'+`${RNFS.DocumentDirectoryPath}${inbox}/${name}`;
alert(" FILE PATH " + realPath);
RNFS.readFile(realPath, 'base64').then(res => {
alert(" RESPONSE " + res)
})
.catch(err => {
(err.message, err.code);
alert("ERROR MSG" + err.message, "ERROR CODE" + err.code)
});
}
}
catch (err) {
if (DocumentPicker.isCancel(err)) {
alert("User Cancel")
} else {
// throw err;
alert(err)
}
}
}


Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.