且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

设置存储在BLOB内容类型的媒体文件

更新时间:2023-02-09 09:03:49

这应该工作:

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.