ios – Tips on how to retailer a photograph url into firestore


I’m attempting to retailer my picture into firebase storage and firestore however Im undecided why I obtain no picture in firebase. That is the code I used to avoid wasting my picture into firestore however I acquired this error

Error whereas changing to information

How I rewrite this code to create a photograph url and to avoid wasting my picture into firebase storage and Firestore

    let imageName = "NewPic"
        let storageRef =
        let imageReference =
        let selectedImage = photographs
        let imageData = selectedImage.jpegData(compressionQuality: 0.8)
        guard imageData != nil else {
            let er = "THIS: Error whereas changing to information"
            return print(er)
        let path = "photographs/(UUID().uuidString).jpg"
        let fileRef =
        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 ])