How to upload an Image and Video ?

Vasanthakumar M 251 Reputation points
2021-04-29T06:37:06.713+00:00

Hi experts,

How to upload an image and Video in Single button click ?

Note : No multiselect . Either Photo or Video must be select .

Is that possible in Xamarin forms?

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,261 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. JarvanZhang 23,931 Reputation points
    2021-04-29T09:36:58.813+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    How to upload an image and Video in Single button click ?

    It supports to upload an image or a video. For this function, you could just use Xamarin.Essentials.FilePicker like below.

       var options = new PickOptions  
       {  
           PickerTitle = "Please select a comic file",  
           FileTypes = FilePickerFileType.Images//or FileTypes = FilePickerFileType.Videos  
       };  
       var result = await FilePicker.PickAsync(options);  
    

    But we cannot list both the videos and images to picker one from them. It only support to set one file type at one time when picking the file. Even when using a customFileType, it will only list the files of one type.

       var customFileType =  
           new FilePickerFileType(new Dictionary<DevicePlatform, IEnumerable<string>>  
           {  
               { DevicePlatform.Android, new[] { "image/*","video/*" } },  
               { DevicePlatform.iOS, new[] { "public.image" } }  
           });  
       var options = new PickOptions  
       {  
           PickerTitle = "Please select a comic file",  
           FileTypes = customFileType  
       };  
       var result = await FilePicker.PickAsync(options);  
    

    Best Regards,

    Jarvan Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.