Re: ImagePicker base64 to firebase storage problem


#1

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.


ImagePicker base64 to Firebase storage problem
#2

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!


#3

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] }

#4

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?


#5

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


#6

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


#7

nope…

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


#8

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.


#9

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?


#10

@aaronksaunders solution is broken with expo 21


#11

How can I do then in expo sdk 21?


#12

@dooboolab any sucess ?


#13

@herve76
No… still suffering…

related:


#14

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…


#15

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


#16

Yes! Finally blob support from RN 0.54.