private async void FinishedPickingAssets(object sender, MultiAssetEventArgs args)
        {
            var results = new List <MediaFile>(24);
            var tcs     = new TaskCompletionSource <IList <MediaFile> >();

            Debug.WriteLine("User finished picking assets. {0} items selected.", args.Assets.Length);

            _preselectedAssets = args.Assets;

            // For demo purposes: just show all chosen pictures in order every second
            foreach (var asset in _preselectedAssets)
            {
                // Get information about the asset, e.g. file patch
                asset.RequestContentEditingInput(new PHContentEditingInputRequestOptions(),
                                                 completionHandler: (input, options) =>
                {
                    var path = input.FullSizeImageUrl.ToString();
                    path     = path.Replace("file://", "");

                    var fileName        = System.IO.Path.GetFileNameWithoutExtension(path);
                    var ext             = System.IO.Path.GetExtension(path);
                    var imgOption       = MediaFileGetImageOptions.CreateDefaultThumb();
                    var thumbImageBytes = AssetImageService.GetImageBytes(asset, imgOption);

                    var thumbnailImagePath =
                        MediaFileHelper.GetOutputPath(MediaFileType.Image, "TmpMedia",
                                                      $"{fileName}-THUMBNAIL{ext}");
                    System.IO.File.WriteAllBytes(thumbnailImagePath, thumbImageBytes);

                    results.Add(new MediaFile
                    {
                        Path        = path,
                        PreviewPath = thumbnailImagePath,
                        Type        = MediaFileType.Image
                    });
                });

                await Task.Delay(250);
            }

            tcs.TrySetResult(results);
            _mediaPickTcs?.TrySetResult(await tcs.Task);
            _preselectedAssets = null;
        }
        public async Task <string> CreatePreviewPath(string path, string type)
        {
            await Task.Delay(TimeSpan.FromMilliseconds(100));

            var fileName = System.IO.Path.GetFileNameWithoutExtension(path);
            var ext      = System.IO.Path.GetExtension(path);

            var strs        = path.Split('/');
            var assetResult = PHAsset.FetchAssetsUsingLocalIdentifiers(strs, null);
            var asset       = assetResult.firstObject as PHAsset;

            var thumbImageBytes =
                AssetImageService.GetImageBytes(asset, MediaFileGetImageOptions.CreateDefaultThumb());

            var thumbnailImagePath =
                MediaFileHelper.GetOutputPath(MediaFileType.Image, "TmpMedia",
                                              $"{fileName}-THUMBNAIL{ext}");

            System.IO.File.WriteAllBytes(thumbnailImagePath, thumbImageBytes);

            return(thumbnailImagePath);
        }