我正在使用const fd = new FormData();
fd.append('image',this.selectedFile,this.selectedFile.name);
console.log(...fd);
软件包,并试图将文件上传到存储设备。
我正在使用react-redux-firebase
HOC并获得withFirebase
,但是this.prop.firebase
和this.props.firebase.storage
是this.props.firebase.storage()
。
当我致电undefined
时,出现以下错误:this.props.firebase.uploadFiles(file)
这是我的Firebase storage is required to upload files
:
index.js
这里是...
import { ReactReduxFirebaseProvider } from 'react-redux-firebase'
import { createFirestoreInstance, getFirestore, reduxFirestore } from 'redux-firestore'
import firebase from './config/firebaseConfig';
const rrfConfig = { userProfile: 'users', useFirestoreForProfile: true };
const store = createStore(rootReducer,
compose(
applyMiddleware(thunk.withExtraArgument({ getFirestore })),
reduxFirestore(firebase),
)
);
const rrfProps = {
firebase,
config: rrfConfig,
dispatch: store.dispatch,
createFirestoreInstance
};
ReactDOM.render(
<Provider store={store}>
<ReactReduxFirebaseProvider {...rrfProps}>
<App />
</ReactReduxFirebaseProvider>
</Provider>, document.getElementById('root')
);
:
./config/firebaseConfig
最后是我的组件:
import firebase from 'firebase/app'
import 'firebase/firestore'
import 'firebase/auth'
const firebaseConfig = {
apiKey: "#######",
authDomain: "#######.firebaseapp.com",
databaseURL: "https://######.firebaseio.com",
projectId: "######",
storageBucket: "########.appspot.com",
messagingSenderId: "##########",
appId: "#:#########:web:############"
};
firebase.initializeApp(firebaseConfig);
export default firebase;
答案 0 :(得分:1)
在您的firebase/storage
文件上导入firebase/auth
之后添加导入./config/firebaseConfig
,然后重试:)