问题描述
let storage = firebase.storage();
let storageRef = storage.ref("EnglishVideos/" + movieTitle + "/" + movieTitle + "_full.mp4");
console.log(storageRef); // looks OK, no error messages
上面的代码有效,从Firebase存储返回的对象具有正确的位置,没有错误消息.
The above code works, the object returned from Firebase Storage has the correct location, no error messages.
但是getDownloadUrl()
不起作用:
let myURL = storageRef.getDownloadUrl();
console.log(myURL); // TypeError: storageRef.getDownloadUrl is not a function
错误为TypeError: storageRef.getDownloadUrl is not a function
.似乎是原型链错误.我正在使用AngularJS,也许我没有在控制器中注入必要的依赖项?我将$firebaseStorage
注入到控制器中,但没有帮助.我从此控制器对Firebase Realtime Database的调用工作正常.
The error is TypeError: storageRef.getDownloadUrl is not a function
. It seems like a prototype chain bug. I'm using AngularJS, maybe I didn't inject a necessary dependency into my controller? I injected $firebaseStorage
into the controller but it didn't help. My calls to Firebase Realtime Database from this controller are working fine.
推荐答案
它是getDownloadURL
,而不是getDownloadUrl
.大写.我的工作代码是
It's getDownloadURL
, not getDownloadUrl
. Capitalization. My working code is
var storageRef = firebase.storage().ref("EnglishVideos/" + movieTitle + "/" + movieTitle + "_full.mp4");
storageRef.getDownloadURL().then(function(url) {
console.log(url);
});
"官方版本是
var storageRef = firebase.storage.ref("folderName/file.jpg");
storageRef.getDownloadURL().then(function(url) {
console.log(url);
});
请注意,在storage
之后需要一个()
,即storage()
.
Note that I needed a ()
after storage
, i.e., storage()
.
这篇关于Firebase Storage getDownloadUrl()“不是函数";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!