react-native-firebase / storage-将图像上传到Firebase存储错误“ _storage.default.storage不是函数”

时间:2019-11-22 04:17:02

标签: react-native react-native-firebase

我已经安装了@ react-native-firebase / app和@ react-native-firebase / storage 以下是我的package.json:

 "dependencies": {
    "@react-native-firebase/app": "^6.0.4",
    "@react-native-firebase/storage": "^6.0.4",
    "firebase": "^5.11.1",

...这是我需要@ react-native-firebase / storage

的地方
import rnFb from '@react-native-firebase/storage';

..这是我用来上传图片的函数:

  uploadImage = localUri =>
    new Promise((resolve, reject) => {
      const localUri2 = Platform.OS === 'ios' ? localUri.replace('file://', '') : localUri;
      const fbUri = Firebase.storage().ref();

      rnFb.storage().ref(localUri2).putFile(fbUri)
        .then(() => { resolve(); })
        .catch((e) => { reject(e); }); 
    });

我收到的错误是:

TypeError: _storage.default.storage is not a function

有人可以帮忙吗? 谢谢!!

1 个答案:

答案 0 :(得分:0)

尝试以下

import storage from '@react-native-firebase/storage';

...
storage().ref(localUri2)
...

import { firebase } from '@react-native-firebase/storage';

...
firebase.storage().ref(localUri2)
...