func uploadGoogleProfileImage(_ image:UIImage, completion: @escaping ((_ url:URL?)->())) {
guard let uid = Auth.auth().currentUser?.uid else { return }
let storageRef = Storage.storage().reference().child("userGoogleImage/\(uid)")
guard let imageData = UIImage.jpegData(compressionQuality: 0.75) else { return }
let metaData = StorageMetadata()
metaData.contentType = "image/jpg"
storageRef.putData(imageData, metadata: metaData) { metaData, error in
if error == nil, metaData != nil {
storageRef.downloadURL{ url, error in
completion(url)
}
} else {
// failed
completion(nil)
}
}
}
该错误显示在使用UIImage.jpegData的行上。不知道为什么会收到此错误?
答案 0 :(得分:0)
jpegData已更改为实例方法而不是类方法。如此改变
guard let imageData = UIImage.jpegData(compressionQuality: 0.75) else { return }
到
guard let data = image.jpegData(compressionQuality: 0.75) else { return }
可以解决问题。