通过Xamarin将视频上传到Azure存储

问题描述 投票:1回答:1

我正在尝试将视频文件上传到我的Azure存储帐户。我已经使用了图像,但是尝试查看上传的视频会显示消息“不支持视频格式或MIME类型”。视频格式为mp4。

我使用以下代码上传:

public async Task UploadVideo(Stream video, string path)
{

    var container = GetContainer("videos");

    // Creates the container if it does not exist
    await CreateContainer(container);

    //Gets the file extension
    string lastPart = path.Split('.').Last();

    // Uploads the video to the blob storage
    CloudBlockBlob videoBlob = container.GetBlockBlobReference(path);
    videoBlob.Properties.ContentType = "video/" + lastPart;
    await videoBlob.UploadFromStreamAsync(video);
} 

难道我做错了什么?

谢谢

编辑:

这是我用来在手机上捕获视频的代码:

    private async Task TakeVideoButton_Clicked(object sender, EventArgs e)
    {
        if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakeVideoSupported)
        {
            await DisplayAlert("No Camera", ":( No camera avaialble.", "OK");
            return;
        }

        mediaFile = await CrossMedia.Current.TakeVideoAsync(new Plugin.Media.Abstractions.StoreVideoOptions
        {
            Name = "video.mp4",
            Directory = "DefaultVideos",
        });

        if (mediaFile == null)
            return;

        await DisplayAlert("Video Recorded", "Location: " + mediaFile.Path, "OK");
        videoStream = mediaFile.GetStream();

        file.Dispose();
    }
c# azure xamarin video xamarin.forms
1个回答
1
投票

我只是在我的手机上测试了这个而不是我的模拟器,它在那里工作得很好,所以我将假设它纯粹是一个模拟器相关的问题。

© www.soinside.com 2019 - 2024. All rights reserved.