我上传了一个图像到firebase,然后我试图检索的URL一旦上传完成,但我得到这个错误。
[Error] Error uploading image: â TypeError: undefined is not an object (evaluating 'snapshot.storageRef.getDownloadURL') â speakers.js:150
TypeError: undefined is not an object (evaluating 'snapshot.storageRef.getDownloadURL') â speakers.js:150
(anonymous function) (speakers.js:161)
promiseReactionJob
图片上传得很好,但我没有得到网址。
var storageRef = firebase.storage().ref();
function uploadPhoto() {
if (selectedFile != null) {
var filePath = "Speaker Images/" + selectedFile.name + Date.now();
var upload = storageRef.child(filePath).put(selectedFile).then(function(snapshot) {
snapshot.storageRef.getDownloadURL().then(function(downloadUrl) {
console.log(downloadUrl);
uploadImageUrl = downloadUrl;
if (docId != null) {
updateSpeaker();
} else {
createNewSpeaker();
}
});
})
.catch(function(error) {
console.error("Error uploading image: ", error);
});
} else {
if (docId != null) {
updateSpeaker();
} else {
createNewSpeaker();
}
}
}
快照看起来不错。
[Log] Ee {bytesTransferred: 30255, totalBytes: 30255, state: "success", metadata: Object, task: e, â¦} (speakers.js, line 150)