react-native-fetch-blob icon indicating copy to clipboard operation
react-native-fetch-blob copied to clipboard

base64() doese not work

Open gonglong opened this issue 8 years ago • 3 comments

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

gonglong avatar Oct 26 '17 08:10 gonglong

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); })

gonglong avatar Oct 26 '17 13:10 gonglong

I tried, but I'm getting

[Error: RNFetchBlob request error: url == nullnull]

rochapablo avatar Jun 01 '18 16:06 rochapablo

same error

romreed avatar Oct 30 '18 09:10 romreed