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 = 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 information"
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
}