2022-12-21

How to download images

I am trying to follow the firebase docs to download my user image from firebase storage but my image is not downloading and I received this error

Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value

What am I missing from this code that will allow me to download my image from firebase storage

       
                    let storage = Storage.storage()
                    let storageRef = storage.reference(forURL: "gs://kaw-tank-work-904a6.appspot.com/ProfileImages/profilePic")
                    
                    
                    
                    
                    storageRef.getData(maxSize: 1 * 1024 * 1024) { data, error in
                         if error != nil {
                            print("there was an error! \(String(describing: error))")
                            print("image was retrieved")
                            // Data for "images/island.jpg" is returned
                            let image = UIImage(data: data!)
                           
                        }
                    }
                }
                )}
            
            
        }
                                   



No comments:

Post a Comment