Guest User

Untitled

a guest
Jan 5th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
  2. if let image = info[.originalImage] as? UIImage {
  3. registrationViewModel.bindableImage.value = image
  4. let imageData = image.jpegData(compressionQuality: 0.5)
  5.  
  6. Alamofire.upload(multipartFormData: { (multipartFormData) in
  7. multipartFormData.append(imageData!, withName: "account[user_attributes[profile_picture]]", fileName: "user_profile_picture.png", mimeType: "image/jpeg"); for(key, value) in self.parameters {
  8. multipartFormData.append(value.data(using: String.Encoding.utf8)!, withName: key)
  9. }
  10. }, to: URL_REGISTER,
  11. headers: nil)
  12. {(result) in
  13. switch result {
  14. case .success(let upload, _, _):
  15. upload.uploadProgress(closure: {(Progress) in
  16. print("Upload progress: (Progress.fractionCompleted)")
  17. })
  18. upload.responseJSON { response in
  19. if let JSON = response.result.value {
  20. print("JSON: (JSON)")
  21. }
  22. }
  23. case .failure(let encodingError):
  24. print(encodingError)
  25. }
  26. }
  27. } else {
  28. }
  29. dismiss(animated: true, completion: nil)
  30. }
  31.  
  32.  
  33.  
  34.  
  35. @objc fileprivate func handleRegister() {
  36. self.handleTapDismiss()
  37. guard let username = userNameTextField.text else {return}
  38. guard let email = emailTextField.text else {return}
  39. guard let password = passwordTextField.text else {return}
  40.  
  41. registeringHUD.textLabel.text = "Register"
  42. registeringHUD.show(in: view)
  43.  
  44.  
  45. AuthService.instance.registerUser(email: email, password: password, username: username) { (success) in
  46. if success {
  47. print("user has signed up")
  48.  
  49. // only upload images to backend once you are authorized
  50.  
  51. } else {
  52. self.showHUDWithError()
  53. }
  54. self.dismiss(animated: true, completion: nil)
  55. }
  56.  
  57. }
Add Comment
Please, Sign In to add comment