let storage = firebase.storage();
let storageRef = storage.ref("EnglishVideos/" + movieTitle + "/" + movieTitle + "_full.mp4");
console.log(storageRef); // looks OK, no error messages
The above code works, the object returned from Firebase Storage has the correct location, no error messages.
But getDownloadUrl()
doesn't work:
let myURL = storageRef.getDownloadUrl();
console.log(myURL); // TypeError: storageRef.getDownloadUrl is not a function
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.
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);
});
The "official" version is
var storageRef = firebase.storage.ref("folderName/file.jpg");
storageRef.getDownloadURL().then(function(url) {
console.log(url);
});
Note that I needed a ()
after storage
, i.e., storage()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With