2

Reading the Firebase documentation, once I have uploaded an image data to Firebase storage bucket (using putData() ), I can get a download URL by calling the downloadURL() method from a StorageReference instance.

And so I did :

uploadRef.downloadURL { (url, error) in
    if error != nil {
        print("failed to download url")
    } else {
        let stringURL = url!.absoluteString
        downloadURLCompletion(stringURL)
    }
}

stringURL returns a public URL starting with https://firebasestorage.googleap...

But what I want to get and store in my Firebase database is the internal URI starting with gs://

Is there a way to request it from Firebase IOS SDK ? Firebase UI seems to provide it automaticaly, but I'm not using Firebase UI.

I know that I can generate this URI by using this template :

gs://<bucket_name>/<file_path_inside_bucket>

...but it assumes that I should hard-code the name of my bucket which doesn't make me happy...

Laurent Maquet
  • 320
  • 2
  • 14
  • `uploadRef.description` will give you the `gs://` URL. You may need to add the file you've just uploaded (name + extension, e.g,: `fileName.jpg`) at the end of it (depends on where `uploadRef` is pointing to). – Ido Aug 12 '19 at 12:15

0 Answers0