gpt4 book ai didi

angular - Firebase 存储 : Invalid argument count in `getDownloadURL` : Expected 0 arguments, 收到 1

转载 作者:行者123 更新时间:2023-12-04 17:50:31 25 4
gpt4 key购买 nike

我想在上传图像后立即获取图像的下载 url,我的代码如下所示:

    let image       : string  = 'promo_' + this.username + '_' + new Date() + '.png',
storageRef : any,
parseUpload : any;

return new Promise((resolve, reject) => {

storageRef = firebase.storage().ref('/promos/' + image);
parseUpload = storageRef.putString(this.imageHolder, 'data_url');

parseUpload.on('state_changed', (_snapshot) => {
// We could log the progress here IF necessary
console.log('snapshot progess ' + _snapshot);
},
(_err) => {
reject(_err);
console.log(_err.messsage);
},
(success) => {
resolve(parseUpload.snapshot);
})
}).then(value => {

storageRef.getDownloadURL(url => {
this.list = this.af.list('/promos');
this.list.subscribe(items => {
let metadata = {
customMetadata: {
'title': this.item.title,
'caption': this.item.caption,
'price': this.item.price,
'date': this.item.date,
'typeofselect': this.item.typeofselect,
'username': this.username,
'url': url
}
}
items.push(metadata);
})
}).catch(e => console.log(e.message);

}).catch(function(error) {
console.log(error.message);
});

错误是:

Firebase 存储:“getDownloadURL”中的无效参数计数:预期 0 个参数,收到 1 个

我获取下载网址的方式有问题吗?谢谢。

最佳答案

您不应该将回调函数传递给 getDownloadURL ,因为它不需要参数。它返回 Promise包含网址。 Promise 时可访问 URL解决,在 .then(url => {}) .

storageRef.getDownloadURL()
.then(url => {
// Do something...
});

关于angular - Firebase 存储 : Invalid argument count in `getDownloadURL` : Expected 0 arguments, 收到 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45424416/

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