0
試圖將文件對象傳遞給redux動作並執行redux動作內部的函數,但不確定它的正確方法?但基本上我想從firebase上傳下載完成,以便我可以顯示圖像前端。React Redux Firebase上傳文件對象
createLocation(event) {
event.preventDefault();
const fileObject = this.state.file;
const test = {
fileObject
}
this.props.uploadImage_func(test);
}
和行動功能:
export function uploadImage_func(fileObject) {
return dispatch => {
const fileName = 'myimage';
const storageRef = firebase.storage().ref('test/' + fileName);
const task = storageRef.put(fileObject);
task.on('state_changed',
function complete(snapshot) {
const downloadURL = task.snapshot.downloadURL;
},
).then(function() {
dispatch(attemptLogin({
...downloadURL
}));
});
}
}
錯誤: