当我将图像作为 blob 上传到 Firebase 存储时,我在 Firefox 和 Chrome 中收到 Uncaught [object Object] 错误,但在 Edge 中没有。当我使用下面从 Firebase 站点提取的代码示例时,我得到了错误。表示状态正在运行,进度为 0%。它昨晚还在工作,任何更改都已恢复为工作版本。
var uploadImg = storage.ref().child('images/' + user.uid + '/savedProducts/blah').put(savedImg);
uploadImg.on(firebase.storage.TaskEvent.STATE_CHANGED, // or 'state_changed'
function(snapshot) {
// Get task progress, including the number of bytes uploaded and the total number of bytes to be uploaded
var progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
console.log('Upload is ' + progress + '% done');
switch (snapshot.state) {
case firebase.storage.TaskState.PAUSED: // or 'paused'
console.log('Upload is paused');
break;
case firebase.storage.TaskState.RUNNING: // or 'running'
console.log('Upload is running');
break;
}
},
function (error) {
switch (error.code) {
case 'storage/unauthorized':
// User doesn't have permission to access the object
break;
case 'storage/canceled':
// User canceled the upload
break;
case 'storage/unknown':
// Unknown error occurred, inspect error.serverResponse
break;
}
},
function () {
// Upload completed successfully, now we can get the download URL
var downloadURL = uploadTask.snapshot.downloadURL;
});