dimonovdd / Xamarin.MediaGallery

This plugin is designed to picking and save images and video files from native gallery of Android and iOS devices and capture photos
MIT License
149 stars 18 forks source link

Selected file should have a property to hold path of the actual file. #104

Closed junedmmn closed 1 year ago

junedmmn commented 2 years ago

Summary

Whenever we select or pick a media file using MediaGallery.PickAsync(), the result must have a property that holds the path of the actual file we selected. The result is of type MediaPickResult that has a property named Files. This File is IEnumerable<IMediaFile> and IMediaFile has properties listed below:

public interface IMediaFile : IDisposable
{
    string NameWithoutExtension { get; }
    string Extension { get; }
    string ContentType { get; }
    MediaFileType? Type { get; }
    Task<Stream> OpenReadAsync();
}

Hence, as shown, it doesn't have any property showing path of the actual file that we selected. It is much required feature as we can further operate on the picked file like compressing, showing preview such as thumbnails, and for showing video previews. We can also inject Dependency Services for platform specific functions.

The only thing now we can do is copy the stream to a file using Stream.CopyToAsync(). But this creates a duplicate copy of an already existing file. This takes a long time for video files depending on the size. This is not the proper way, it's just a workaround.

Adding a feature to provide file path of the selected file will be much appreciable. Thanks.

dimonovdd commented 1 year ago

Hi. Duplicate https://github.com/dimonovdd/Xamarin.MediaGallery/issues/41 https://github.com/dimonovdd/Xamarin.MediaGallery/discussions/42

CodingOctocat commented 3 months ago

MAUI's MediaPicker can get the file path (but doesn't support multiple choices 😂), so it's 2024, can Xamarin.MediaGallery get the file path?