Hey I need help with this coding, i'm not sure what has happened. It was working the other day. The error comes up after if let ur; = metaData?.downladURL()
func uploadProfileImage(_ image:UIImage, completion: @escaping ((_ url:URL?)->())) {
guard let uid = Auth.auth().currentUser?.uid else { return }
let storageRef = Storage.storage().reference().child("user/(uid)")
guard let imageData = UIImageJPEGRepresentation(image, 0.75) else { return }
let metaData = StorageMetadata()
metaData.contentType = "image/jpg"
storageRef.putData(imageData, metadata: metaData) { metaData, error in
if error == nil, metaData != nil {
if let url = metaData?.downloadURL() {
completion(url)
} else {
completion(nil)
}
// success!
} else {
// failed
completion(nil)
}
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…