Reputation: 4003
In my expo project I can upload images to firebase and can view from my firebase console but I want to get the url of that uploaded image how can I get the url my upload function is looks like.
uploadImage = async (uri, imageName) =>{
const response = await fetch(uri);
const blob = await response.blob();
// calling firebase storage api
var ref = Firebase.storage().ref().child("images/posts/"+imageName);
console.log("*****************firebase***************")
console.log(ref)
console.log("*****************firebase***************")
return ref.put(blob);
}
Upvotes: 1
Views: 2687
Reputation: 22209
You can use getDownloadUrl
method on directly on your storage reference to get the result in the form of a promise
ref.getDownloadURL().then((url) => console.log(url))
Upvotes: 4