0

I have read quite a few posts about this (e.g. Save base64 encoded image to Firebase Storage) but cannot make it work.

I am using the example from https://firebase.google.com/docs/storage/web/upload-files#upload_from_a_string (doing this in React Native):

console.log('Writing a base64 string');
ref = await firebase.storage().ref('test').child(Date.now().toString());
message = '5b6p5Y+344GX44G+44GX44Gf77yB44GK44KB44Gn44Go44GG77yB';
await ref.putString(message, 'base64').then(snapshot => {
  console.log('.... Done');
});

And I get the following error:

[17:53:23] Possible Unhandled Promise Rejection (id: 0):
[17:53:23] FirebaseStorageError {
[17:53:23]   "code_": "storage/invalid-format",
[17:53:23]   "message_": "Firebase Storage: String does not match format \'base64\': Invalid character found",
[17:53:23]   "name_": "FirebaseError",
[17:53:23]   "serverResponse_": null,
[17:53:23] }
Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
Yossi
  • 5,577
  • 7
  • 41
  • 76
  • Are you sure that's a valid base64 string? – Doug Stevenson Nov 13 '18 at 16:39
  • I took this from the example in https://firebase.google.com/docs/storage/web/upload-files#upload_from_a_string. I also tried shorter strings, like 'dGV4dA==' (encoded 'text' in https://www.base64encode.org/) – Yossi Nov 13 '18 at 16:47
  • Then you should file a bug report. http://firebase.google.com/support/contact/bugs-features – Doug Stevenson Nov 13 '18 at 16:49
  • Thanks Doug, I will. It seems, however, that it works for some people... See https://stackoverflow.com/questions/37352884/save-base64-encoded-image-to-firebase-storage. – Yossi Nov 13 '18 at 17:01
  • Thanks to @soutot it works. See: https://stackoverflow.com/questions/52157253/firebase-storage-string-does-not-match-format-base64-invalid-character-found/52174058#52174058 – Yossi Nov 13 '18 at 21:30

0 Answers0