iosiphoneswiftuiimagepickercontroller

How do you get image file name from UIImagePickerController?


I'm not getting the image name from photo library. Anyone here knows a proper way to get image name?

Note: PHAsset.fetchAssets(withALAssetURLs: [imageURL], options: nil) this is deprecated.

Swift only

Thanks


Solution

  • I found a way

    if let asset = info["UIImagePickerControllerPHAsset"] as? PHAsset{
                if let fileName = asset.value(forKey: "filename") as? String{
                print(fileName)
                }
            }
    

    This will return you the actual file name in the photo library.