Azure媒体服务删除文件

时间:2016-03-04 16:03:24

标签: azure-media-services

我尝试使用此代码删除媒体服务中的文件,但它无法正常工作(没有任何反应):

CloudMediaContext context = new CloudMediaContext(ConfigurationManager.AppSettings["MediaServicesAccountName"], ConfigurationManager.AppSettings["MediaServicesAccountKey"]);

IAsset asset = context.Assets.First();


ILocator sasLocator = asset.Locators.Where(l => l.Type == LocatorType.Sas).First();


IAssetFile assetFile = asset.AssetFiles.ToList().First();

assetFile.Delete();

我使用此代码作为示例: How to get the duration of a video from the Azure media services?

我认为我的问题是由于“定位器”我不明白如何创建和操作。

1 个答案:

答案 0 :(得分:0)

事实上它更简单...... 为此,我们不需要使用“定位器”来发现视频:

IAsset GetAsset(string name)
{ 
    var assets = _context.Assets.Where(a => a.Name == name).ToList();
    if (!assets.Any())
    {
        //no video found
    }
    return assets.First();
}

你可以删除:

GetAsset("test-video").Delete();