react-native-fetch-blob
react-native-fetch-blob copied to clipboard
base64() doese not work
I want to download an image and convert its content into base64 string.
Here is what I did:
RNFetchBlob .config({ fileCache : false, appendExt : imageExtension, }) .fetch('GET', this.props.imageUrl, { //some headers .. }) .then((res) => { // here the data would be something like {-10: '', -25: null} const data = res.base64(); })
curiously, sometime later, the data would be changed into something like {-10: '"", -25: "quite long base64 string"}. I guess something done in native thread and changed the data. Anyway , i cannot get the base64 string. Is there anything I am wrong ?
iOS11 RN 0.48
Thanks
I changed the way and it works as expect. But it would be better if base64() works
let imagePath = null; RNFetchBlob .config({ fileCache : true, appendExt : imageExtension, }) .fetch('GET', this.props.imageUrl, { //some headers .. }) .then((res) => { imagePath = res.path(); // changes to use readFile return res.readFile('base64'); }).then((base64ImageData)=>{ // I can use the base64 data now // just for removing template file in case return RNFetchBlob.fs.unlink(imagePath); })
I tried, but I'm getting
[Error: RNFetchBlob request error: url == nullnull]
same error