itinance / itinance/react-native-fs

How to get File path from the document directory in iOS and convert that file to Base64.

Open
#915 6 comments 1 reaction 0 assignees View on GitHub
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)
}
}
}
![IMG_FAE8EA386E01-1](https://user-images.githubusercontent.com/43564071/89290640-c8b4d280-d676-11ea-886b-a75fa572b45f.jpeg)
![IMG_FF3AB639131A-1](https://user-images.githubusercontent.com/43564071/89290655-cd798680-d676-11ea-9803-dee32c0468d8.jpeg)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.