Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Value of type 'StorageReference' has no member 'put' [duplicate]

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])
                }
            })
        }
    }
like image 272
Victor Apeland Avatar asked May 21 '17 20:05

Victor Apeland


1 Answers

According to Firebase's migration support, it has been changed to putData(_:metadata:completion:)

like image 118
Tristan Beaton Avatar answered Oct 21 '22 07:10

Tristan Beaton