Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

base64() doese not work #579

Open
gonglong opened this issue Oct 26, 2017 · 3 comments
Open

base64() doese not work #579

gonglong opened this issue Oct 26, 2017 · 3 comments

Comments

@gonglong
Copy link

gonglong commented Oct 26, 2017

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
Copy link
Author

gonglong commented Oct 26, 2017

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

@rochapablo
Copy link

I tried, but I'm getting

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

@romreed
Copy link

romreed commented Oct 30, 2018

same error

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants