小编guy*_*rgo的帖子

如何在单个 azure blob 请求上设置内容处置?

我有一个托管视频的应用程序,我们最近迁移到了 Azure。

在我们的旧应用程序中,我们为用户提供了播放或下载视频的功能。然而,在 Azure 上,我似乎必须在我想要的功能之间进行选择,因为必须在文件上而不是在请求上设置内容配置。

到目前为止,我提出了两个非常糟糕的解决方案。

第一个解决方案是通过我的 MVC 服务器流式传输下载。

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]);
                        CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
                        CloudBlobContainer container = blobClient.GetContainerReference("videos");
                        string userFileName = service.FirstName + service.LastName + "Video.mp4";
                        Response.AddHeader("Content-Disposition", "attachment; filename=" + userFileName); // force download
                        container.GetBlobReference(service.Video.ConvertedFilePath).DownloadToStream(Response.OutputStream);
                        return new EmptyResult();
Run Code Online (Sandbox Code Playgroud)

此选项适用于较小的视频,但对我的服务器来说非常繁重。对于较大的视频,操作超时。

第二种选择是将每个视频托管两次。

这个选项显然很糟糕,因为我将不得不支付双倍的存储成本。

video azure content-disposition http-headers azure-storage-blobs

3
推荐指数
1
解决办法
2597
查看次数