HomeiOS Developmentios - The way to retailer a photograph url into firestore

ios – The way to retailer a photograph url into firestore


I’m making an attempt 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 save lots of my picture into firestore however I obtained this error

Error whereas changing to knowledge

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 = Storage.storage().reference()
        let imageReference = storageRef.baby(imageName)
        
        
       
        let selectedImage = photographs
        let imageData = selectedImage.jpegData(compressionQuality: 0.8)
        
        guard imageData != nil else {
            let er = "THIS: Error whereas changing to knowledge"
            return print(er)
        }
        
       
        let path = "photographs/(UUID().uuidString).jpg"
        let fileRef = storageRef.baby(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 {
                        print(err.localizedDescription)
                        return
                    }
                    
                    guard let validUrl = url else {
                        print("url was not legitimate")
                        return
                    }
                    
                    
                    let db = Firestore.firestore()
                    db.assortment("person").doc("username").setData(["username" : name, "bio": profileText, "profileImage" : imageName ])
                    
                    
                    

                return
            }

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments