I'm trying to upload image to firebase storage with this code:
const firebase = useFirebase();
const handleSubmit = e => {
e.preventDefault();
// state.title && dispatch(createItems(state));
firebase
.storage()
.ref(`images/${state.title}`)
.child(state.title)
.getDownloadURL()
.then(url => setState({ ...state, avatarURL: url }));
};
And it's not working. Almost the same code works fine with react-firebase-file-uploader. Does any anyone has idea why?
Thanks!
.ref(`images/${state.title}`).child(state.title)means that you'll havestate.titlein the file path as well as being the file name. Is that what you want? - Renaud Tarnec