设置存储在BLOB内容类型的媒体文件 [英] Set Content-type of media files stored on Blob

查看:340
本文介绍了设置存储在BLOB内容类型的媒体文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有托管在Azure上一个网站。据媒体为主,而且我们正在使用JWPlayer播放与HTTP pseudostreaming媒体。媒体文件存储在BLOB 3种格式 - MP4,OGG,WEBM

We have a website hosted on Azure. It is media based, and we are using JWPlayer to playback media with HTTP pseudostreaming. The media files are stored on blob in 3 formats - mp4, ogg, webm.

问题是媒体文件的内容类型设置为应用程序/八位字节流的所有类型。由于这种有在媒体播放和进度条的一些问题。

The issue is the content type of media files is set as application/octet-stream for all types. Due to this there are some issues in media playback and progress bar.

如何设置适当的内容类型存储在BLOB文件(比如 - 视频/ MP4,视频/ OGG格式,视频/ W​​EBM)

How can I set the appropriate Content-type of files stored on blob (like - video/mp4, video/ogg, video/webm)?

我不想在Blob接口会做手工为每个文件。必须有一些其他的方式做到这一点,我是不知道的。也许一个配置文件,设置文件等排序。或者一个code座来设置内容类型为存储在文件夹中的所有文件。

I do not want to do it manually for each file by going in blob interface. There must be some other way to do it which I am not aware of. Perhaps a config file, settings file, etc sorts. Or perhaps a code block to set up the Content-type for all files stored in a folder.

有什么建议?
谢谢

Any suggestions? Thanks

推荐答案

这应该工作:

foreach (var blob in CloudStorageAccount.Parse("YOURCONNECTIONSTRING").GetContainerReference("thecontainer").ListBlobs().OfType<CloudBlockBlob>())
{
    if (Path.GetExtension(blob.Uri.AbsoluteUri) == ".mp4")
    {
        blob.Properties.ContentType = "video/mp4";
    }
    // repeat ad nauseam
    blob.SetProperties();
}

或设置一个字典,所以你不必写一堆if语句。

Or set up a dictionary so you don't have to write a bunch of if statements.

这篇关于设置存储在BLOB内容类型的媒体文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆