gpt4 book ai didi

上传到存储时 Firebase Uncaught [object Object]

转载 作者:行者123 更新时间:2023-12-02 03:14:35 35 4
gpt4 key购买 nike

当我将图像作为 blob 上传到 Firebase 存储时,我在 Firefox 和 Chrome 中收到未捕获的 [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;
});

最佳答案

这是一个迟到的答案,但仍然如此。我希望这可以帮助人们。

当您尝试将 blob 上传到存储时,您使用了该方法

storage.ref().child('images/' + user.uid + '/savedProducts/blah').put(savedImg);

在我的例子中,为了将 blob 放入 firebase 存储中,我需要使用方法 putString(saveImage, 'data_url')'data_url 是格式。

完整代码

storage.ref().child('images/' + user.uid + '/savedProducts/blah').putString(saveImage, 'data_url');

关于上传到存储时 Firebase Uncaught [object Object],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37841054/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com