UnityNativeGallery icon indicating copy to clipboard operation
UnityNativeGallery copied to clipboard

iOS: Get original filename instead of PickedMedia1 etc

Open zxubian opened this issue 4 years ago • 1 comments

Description of the bug User selects file (e.g. Video1.mp4) The returned path from the plugin has the filename pickedMedia1.mp4

Platform specs

  • Unity version: 2019 LTS
  • Platform: iOS
  • Device: iPhone Xs, iOS 14.6
  • How did you download the plugin: UPM (github)

For reference: https://stackoverflow.com/questions/37383491/get-original-video-name-as-selected-from-uiimagepickercontroller

zxubian avatar Jul 07 '21 07:07 zxubian

At the moment, I'm not planning to implement this feature. I can't anyways because I don't have access to my Mac workstation and I'd need to have at least one iOS 14+ device and one iOS 13- device.

In NativeGallery.mm, you'll need to change most of the lines with pickedMediaSavePath:

  • Inside (PHPickerViewController *)picker didFinishPicking function (iOS 14+), you need to determine the filename from itemProvider.suggestedName (I don't know if it can be null, so you should check for null values, as well)
  • Inside (UIImagePickerController *)picker didFinishPickingMediaWithInfo function (iOS 13-), you can use the method suggested in the stackoverflow entry you've posted

yasirkula avatar Jul 07 '21 07:07 yasirkula