I updated to firebase storage 4.0, and now I get this error saying storageRef has no member "put". It worked before in the old version of Firebase.
if let selectedImage = selectedImageFromPicker {
profilePic.image = selectedImage
if let uploadData = UIImagePNGRepresentation(selectedImage) {
let storageRef = Storage.storage().reference().child("profile pictures").child("\(Auth.auth().currentUser?.uid).png")
storageRef.put/*error here*/(uploadData, metadata: nil, completion: {
(metadata, error) in
if error != nil {
print(error!)
return
}
print(metadata!)
if let profilePictureURL = metadata?.downloadURL()?.absoluteString {
let ref = FIRDatabase.database().reference()
let usersreference = ref.child("users").child(Auth.auth().currentUser?.uid).child("data")
usersreference.updateChildValues(["profile picture": profilePictureURL])
}
})
}
}
According to Firebase's migration support, it has been changed to putData(_:metadata:completion:)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With