user523234 user523234 - 10 months ago 52
iOS Question

Get Firebase database file donwloadURL manually - iOS platform

I know if I upload an image file to Firebase Database via

method. In return, I can get the

But what if I do not want to store this
. And later, I want to download this image.

Question: Can I get this downloadURL if I know the image's file name?


If you know the file name (or really: the file path) of the image in Firebase Storage, you can get the download URL using:

// Create a reference to the file you want to download
let starsRef = storageRef.child("images/stars.jpg")
// Fetch the download URL
starsRef.downloadURLWithCompletion { (URL, error) -> Void in
  if (error != nil) {
    // Handle any errors
  } else {
    // Get the download URL for 'images/stars.jpg'

See the Firebase Storage documentation on downloading files from where I got the above example.