Asnad Atta
Asnad Atta

Reputation: 4003

Get URL of file after uploading to Firebase with React Native and Expo

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

Answers (1)

Pritish Vaidya
Pritish Vaidya

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

Related Questions