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) {
let datapath = Platform.OS === 'ios' ? res.uri.replace("file://", "") : res.uri
alert(" FILE PATH IS " + datapath)
RNFetchBlob.fs.readFile(datapath, 'base64')
.then((data) => {
let base = data.replace(/\s+/g, '')
alert(" BASE64 IS " + base)
})
.catch((errorMessage, statusCode) => {
alert(" ERROR MESSAGE IS " + errorMessage)
// error handling
})
}
}
catch (err) {
if (DocumentPicker.isCancel(err)) {
alert("User Cancel")
} else {
// throw err;
alert(err)
}
}
}
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) {