我试图使用getDownloadURL()
方法来检索存储在firebase存储中的图像的url.
奇怪的是它返回一个url,它是一个对象,而不是图像
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓例子URL↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ ↓↓↓↓↓↓↓↓↓↓↓↓ https: /////////////// /说明↑↑↑↑↑↑↑↑↑↑例子URL↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑
我在网上做了一些研究,发现显示我的图像的正确网址应该是这样的......
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓例子URL↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ ↓↓↓↓↓↓↓↓↓↓↓↓ https:
//firebasestorage.googleapis.com/v0/b/example.appspot.com/o/images%2Fcat.png? alt
= media & token = sometoken↑↑↑↑↑化学网站↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑
但我不知道如何通过使用getDownloadURL()
... 获取网址
这是我的代码......
var storage = firebase.storage();
$scope.getImgUrl = function(file) {
storage.ref("images/" + file + ".png")
.getDownloadURL()
.then(function onSuccess(url) {
return url;
})
.catch(function onError(err) {
console.log("Error occured..." + err);
})
}
Run Code Online (Sandbox Code Playgroud)
任何的想法?