Firebase Storage: String does not match format 'base64': Invalid character found : <p>I'm working on a react-native and I need to upload an image to Firebase using <a href="https://firebase.google.com/docs/storage/web/start" rel="noreferrer">Firebase Storage</a>. I'm using <a href="https://github.com/marcshilling/react-native-image-picker" rel="noreferrer">react-native-image-picker</a> to select the image from the phone which gives me the base64 encoded data.</p>

<p>When I try to upload the image to Firebase it gives me the error <code>Firebase Storage: String does not match format 'base64': Invalid character found</code> but I already checked if the string is a valid base64 string with regex and it is!</p>

<p>I already read a few answers from here but I tried all that. Here's my code:</p>

<pre><code>function uploadImage(image){
  const user = getCurrentUser();
  const refImage = app.storage().ref(`profileImages/${user.uid}`);

  refImage.putString(image, 'base64').then(() =&gt; {
    console.log('Image uploaded');
  });
}
</code></pre>

<p>The image picker:</p>

<pre><code>ImagePicker.showImagePicker(ImageOptions, (response) =&gt; {
  if (response.didCancel) {
    console.log('User cancelled image picker');
  }
  else if (response.error) {
    console.log('ImagePicker Error: ', response.error);
  }
  else if (response.customButton) {
    console.log('User tapped custom button: ', response.customButton);
  }
  else {
    uploadImage(response.data);
  }
});
</code></pre>
