You can do it as follows:
1) Upload the file to the firebase repository and get the URL to download:
static func upload(_ image: UIImage,
completion: @escaping (_ hasFinished: Bool, _ url: String) -> Void) {
let data: Data = UIImageJPEGRepresentation(image, 1.0)!
let ref = FIRStorage.storage().reference(withPath: "media/" + userId + "/" + unicIdGeneratedLikeYouWant)
ref.put(data, metadata: nil,
completion: { (meta , error) in
if error == nil {
completion(true, (meta?.downloadURL()?.absoluteString)!)
} else {
completion(false, "")
}
})
Then save the URL of the uploaded photo to node user with FIRDatabase. It will look like this:

But these will be id messages, for example, instead of mediaRef10andmediaRef700
So, you will have links to photos in custom node, and you can easily get them with good performance.
source
share