I tried using the getDownloadURL() method to retrieve the url of my images that are stored in the firebase repository.
It is strange that it returns a url that is an object, not images
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ EXAMPLE URL ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ ↓↓↓↓ ↓↓↓↓↓↓↓↓↓↓↓ https://firebasestorage.googleapis.com/v0/b/example.appspot.com/o/images%2Fcat.png ↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ Example URL ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑
I did some research on the Internet and found out that the correct URL to display my image should be like this ...
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ EXAMPLE URL ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ ↓↓↓↓ ↓↓↓↓↓↓↓↓↓↓↓ https://firebasestorage.googleapis.com/v0/b/example.appspot.com/o/images%2Fcat.png?alt=media&token=sometoken
↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ example URL ↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑
But I don't know how to get the url using getDownloadURL() ...
Here is my code ...
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); }) }
Any idea?
source share