1

I just started to use Firebase/Storage and I have the following question.

First here is the situation:

I have an image called myImage.gif that I uploaded to Firebase/Storage. It all works fine. I get a download URL for recovering the file at a later time.

For reference this is how I get the downloadURL:

......
imageRef.downloadURL(completion: {
    (url: URL?, error: Error?) in
    if (error == nil) {
        if let downloadUrl = url {
            // Get the download URL.
            let downloadURL = downloadUrl.absoluteString
            print("This is the downloadURL: \(downloadURL)")
        }
    } else {
        print("Error:\n\(error!)")
    }
});

The URL for downloading looks like this:

https://firebasestorage.googleapis.com/.../CollectionName%2myImage.gif?alt=media&token=abc12d34-2ex1-4xyz-5re4-c6d8ggqde765

And if I use it I can indeed download the file.

Now here is the question:

Being able to download the file is all right, but this is not exactly what I am interested in. I want a URL that I can use in a web page to bring the image to the view of the user, in other words to use like this:

<img src="theURL" alt="My wonderful image!">

How can I get such a URL? (instead of one for downloading)

Michel
  • 10,303
  • 17
  • 82
  • 179
  • 1
    This is precisely how the download URL is normally used. Are you saying it doesn't work? – Doug Stevenson Oct 25 '18 at 07:32
  • Possible duplicate of: https://stackoverflow.com/questions/39398282/retrieving-image-from-firebase-storage-using-swift – Jacob Ahlberg Oct 25 '18 at 10:25
  • Possible duplicate of [Retrieving image from Firebase Storage using Swift](https://stackoverflow.com/questions/39398282/retrieving-image-from-firebase-storage-using-swift) – Jacob Ahlberg Oct 25 '18 at 10:26
  • Sorry. Yes it works. Since I did not see the image, but a download dialog when I clicked the link I misunderstood, but when used with the proper syntax in javascript, it works. – Michel Oct 26 '18 at 09:58

0 Answers0