SHARE
TWEET

Untitled

a guest Apr 20th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
  2.     dismiss(animated: true)
  3. }
  4.  
  5. func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
  6.     var imageURL: NSURL ?
  7.         var selectedImageFromPicker: UIImage ?
  8.  
  9.             if
  10.     let originalImage = info[UIImagePickerController.InfoKey.originalImage] {
  11.         selectedImageFromPicker = originalImage as!UIImage
  12.     }
  13.  
  14.     let uniqueImage = NSUUID().uuidString
  15.     let storageRef = Storage.storage().reference().child("gallery").child("\(uniqueImage).jpg")
  16.     if var selectedImage = selectedImageFromPicker {
  17.         if let imageURL = info[UIImagePickerController.InfoKey.imageURL] as ? NSURL {
  18.  
  19.             if let uploadImage = selectedImage.jpegData(compressionQuality: 0.1) {
  20.                 selectedImage = UIImage(data: uploadImage) !
  21.                    
  22.                 gallery.append(INSPhoto(image: selectedImage, thumbnailImage: selectedImage))
  23.                
  24.                 uploadImageToFirebase(storage: storageRef, data: uploadImage)
  25.             }
  26.  
  27.             self.collectionView ? .reloadData()
  28.  
  29.         }
  30.         dismiss(animated: true)
  31.     }
  32.  
  33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top