ios – How do I save a picture to firebase


I’m attempting to retailer my picture into firebase storage and put the picture url into firestore however Im not receiving a picture in firebase. That is the code I used to save lots of my picture into firestore however I obtained this error

Error whereas changing to information

Why am I receiving this error that’s stopping me from saving my picture and How I rewrite this code to create a photograph url and to save lots of my picture into firebase storage and Firestore

    let imageName = "NewPic"
    let storageRef =
    let imageReference = storageRef.little one(imageName)   
    let selectedImage = photos
    let imageData = selectedImage.jpegData(compressionQuality: 0.8)
    guard imageData != nil else {
        let er = "THIS: Error whereas changing to information"
        return print(er)
    let path = "photos/(UUID().uuidString).jpg"
    let fileRef = storageRef.little one(path)
    let uploadTask = fileRef.putData(imageData!, metadata: nil) {metaData, error in
        print("THIS: from uploadTAsk")
        if error == nil && metaData != nil {
            imageReference.downloadURL { (url, error) in
                if let err = error {
                guard let validUrl = url else {
                    print("url was not legitimate")
                let db = Firestore.firestore()
                db.assortment("person").doc("username").setData(["username" : name, "bio": profileText, "profileImage" : imageName ])