Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2018
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 2.08 KB | None | 0 0
  1. @objc func handleSignup(){
  2.         guard let email = emailTextField.text, email.count > 0 else { return }
  3.         guard let password = paswordTextField.text, password.count > 0 else { return }
  4.         guard let username = usernameTextField.text, username.count > 0 else { return }
  5.        
  6.         Auth.auth().createUser(withEmail: email, password: password) { (user, err) in
  7.             if let error = err{
  8.                 print("Failed to create the user", error.localizedDescription)
  9.                 return
  10.             }
  11.             print("The user is successfully created ", user?.user.uid ?? "")
  12.            
  13.             guard let image = self.buttonView.imageView?.image else{ return }
  14.            
  15.             guard let uploadData = image.jpegData(compressionQuality: 0.3) else { return }
  16.             print(uploadData)
  17.             let uuid = NSUUID().uuidString
  18.            
  19.             print("The uuid is \(uuid)")
  20.             print("Coming to here 1")
  21.             Storage.storage().reference().child("profileImages").child(uuid).putData(uploadData, metadata: nil) { (metadata, error) in
  22.                
  23.                 DispatchQueue.main.async {
  24.                     print("How about here?")
  25.                 }
  26.                 if let error = error{
  27.                     print("Failed to upload image with \(error.localizedDescription)")
  28.                     return
  29.                 }
  30.                 print("Got here")
  31.                 if true {
  32.                     print("Got here")
  33.                     Storage.storage().reference().child("profileImages").child(uuid).downloadURL(completion: { (url, err) in
  34.                         print("in Downloading url \(url) \(err)")
  35.                         if let error = err{
  36.                             print("There is some error fetching the urls \(error.localizedDescription)")
  37.                         }
  38.                         guard let downloadurl = url?.absoluteString else { return }
  39.                         print("The fetched url is ", downloadurl)
  40.                     })
  41.                 }
  42.                
  43.             }
  44.         }
  45.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement