filestack / filestack-ios

Official iOS SDK for Filestack - API and content management system that makes it easy to add powerful file uploading and transformation capabilities to any web or mobile application.
https://www.filestack.com
MIT License
55 stars 36 forks source link

Camera option leads to PhotoPicker #37

Closed schmidan closed 5 years ago

schmidan commented 5 years ago

since we re-enabled multi file upload via: config.maximumSelectionAllowed = Config.kMaximumSelectionNoLimit

we had reports from users stating that they could not use the camera as a local source anymore.

you can reproduce this by adding the line config.maximumSelectionAllowed = 2 to the DemoApp and try to take a Photo with the Camera

Skimming thru the code i have this question: does it mean that by using either a maximumSelection higher than 1 or using showEditorBeforeUpload = true we prevent the user from using the Camera as source?

rob-barber commented 5 years ago

Coming up with the same issue. Downloaded sample to vet the use of the picker.

Looking at the source code the behavior is coming from "ImagePickerUploadController.swift" at line 49.

func start() {
    if shouldUseCustomPicker {
      viewController.present(customPicker, animated: true, completion: nil)
    } else {
      viewController.present(nativePicker, animated: true, completion: nil)
    }
  }

And the shouldUseCustomPicker computed property at line 59.

  var shouldUseCustomPicker: Bool {
    let multipleSelectionAllowed = config.maximumSelectionAllowed != 1
    let editingEnabled = config.showEditorBeforeUpload
    return multipleSelectionAllowed || editingEnabled
  }

The customPicker from the start() function then uses the PhotoPickerController on line 80 of the same file. Which just opens up an image picker screen.

  var customPicker: UINavigationController {
    let picker = PhotoPickerController(maximumSelection: config.maximumSelectionAllowed)
    picker.delegate = self
    let navigation = picker.navigation
    navigation.modalPresentationStyle = config.modalPresentationStyle
    return navigation
  }

So setting config.maximumSelectionAllowed to anything other than 1 OR setting config.showEditorBeforeupload = true will prevent image/video capture.

This seems like it was intended. It's pretty misleading though and should probably be changed.

rnine commented 5 years ago

Fixed in commit eea617e.