我已经阅读了很多有关此的文章(例如Save base64 encoded image to Firebase Storage),但无法使其正常工作。
我正在使用https://firebase.google.com/docs/storage/web/upload-files#upload_from_a_string中的示例(在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');
});
然后出现以下错误:
[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] }