0

I have a problem with my first app I've ever wrote. I watched a tutorial on YouTube on how to let users signup with Firebase and choose a profile picture. In the video everything went as it should, but in my project it gives me following bug:

Value of type 'StorageReference' has no member 'put'

I already saw a post on this topic, but I coldnt work with this answer given there (Value of type 'StorageReference' has no member 'put').

Here is my complete code:

let uploadTask = imageRef.put(data!, metadata: nil, completition: { (metadata, error) in

                    if err != nil{
                        print(err!.localizedDescription)
                    }

                    imageRef.downloadURL(completion: { (url, er) in
                        if er != nil{
                            print(er!.localizedDescription)
                        }

                        if let url = url {

                            let userInfo: [String: Any] = ["uid" : user.uid,
                                                           "full name" : self.nameField.text!,
                                                           "urlToImage" : url.absoluteString]

                            self.ref.child("users").child(user.uid).setValue(userInfo)


                            let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController
                            (withIdentifier: "userVC")

                            self.present(vc, animated: true, completion: nil)
                        }

                    })

                })

The error comes in the first line.

Jake Symons
  • 468
  • 2
  • 10
  • 19
adrian_arvice
  • 25
  • 1
  • 8
  • According to the duplicate question your linked: `put(data!...)` => `putData(data!...)` Also, if you write just `put`, does the autocompletion help you? – Larme Feb 13 '18 at 18:07
  • Unfortunately not :-( I tried pretty much every solution I found but nothing helped me, so I needed to ask again. – adrian_arvice Feb 14 '18 at 17:32

1 Answers1

1

According to the documentation and the question you linked, the latest version of Firebase uses putData, not put.

let uploadTask = imageRef.putData(data!, metadata: nil) { (metadata, error) in

  // your code here

})
Jen Person
  • 7,356
  • 22
  • 30