question

VasanthakumarM-3635 avatar image
0 Votes"
VasanthakumarM-3635 asked JarvanZhang-MSFT commented

How to upload an Image and Video ?

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?

dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JarvanZhang-MSFT avatar image
0 Votes"
JarvanZhang-MSFT answered JarvanZhang-MSFT commented

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.


· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi ,
Here can i compress an Image size

for example I'm uploading an img size => 4MB . While uploading it will compress to <1MB


@JarvanZhang-MSFT can possible

0 Votes 0 ·

The Xam.Plugin.Media plugin provides the compression option while picking the image.

var file = await Plugin.Media.CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions
{
    PhotoSize = Plugin.Media.Abstractions.PhotoSize.Small,
});
0 Votes 0 ·

For Video How to Compress it ? @JarvanZhang-MSFT

0 Votes 0 ·
Show more comments