Re: ImagePicker base64 to firebase storage problem

I already uploaded this issue in below url.

I want to solve this issue as soon as possible to go on to next step.
I really don’t wan t to use Amazon s3.

Sorry for bothering by writing the same issues.

Thank you.

2 Likes

Hi,

Could you try the debugging by converting go a data URI and showing with an Image component? So prepend data:image/png;base64 to the string and use that as the URI for an Image component.

That way you can see if the base64 indeed has an error!

I have tested this and the Image will appear properly when added

    this.setState({avatarSource:'data:image/jpeg;base64,' + pickerResult.base64})

Then in my render, this works…

    {this.state.avatarSource == null ? null :  
        <Image 
          source={{uri:this.state.avatarSource}}
          style={{ height: 200, width: 300 }}
        />}

but that same value throws and error when trying to upload to firebase.

[exp] when trying to load : FirebaseStorageError {
[exp]   "code_": "storage/invalid-format",
[exp]   "message_": "Firebase Storage: String does not match format 'base64': Invalid character found",
[exp]   "name_": "FirebaseError",
[exp]   "serverResponse_": null,
[exp] }
1 Like

could not get this working at all… went another direction using byteArray and I am able to get uploads working see - Expo and uploading image Blobs?

Yeah I’m not sure why Firebase is complaining if it gets rendered properly as a data URI… :thinking:

Could it be that Firebase wants a base64 string without data:image/jpeg;base64, prefixed to it? That might explain the “invalid character” error.

nope…

i tried all possibilities on this one… including and excluding data:image/jpeg;base64 treating it as a data_url also, nothing works

2 Likes

Aaron is right, I was facing the exact same problem. Firebase keeps throwing this error even when you provide a valid base64 string. Very weird indeed.

1 Like

11

Will this kind of implementation work?
The user have to login to webview again to handle firebase session right?

Will this be a good implementation? What would you think?

@aaronksaunders solution is broken with expo 21

How can I do then in expo sdk 21?

@dooboolab any sucess ?

@herve76
No… still suffering…

related:

3 Likes

For me it works fine as long as remote debugger is on. When I turn it off I’m getting the Invalid character found error. So weird…

this might be useful to you: https://github.com/expo/firebase-storage-upload-example

1 Like

Yes! Finally blob support from RN 0.54.

1 Like