获取异常在媒体服务azure上传文件时

时间:2016-10-27 13:04:07

标签: azure azure-media-services

我想在媒体服务上上传文件。当我上传文件时,它会在一段时间后发出异常。 这是例外

at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Microsoft.WindowsAzure.MediaServices.Client.AssetFileData.Upload(String path)
at OnDemandEncoding.Models.Azure.UploadFile(String filePath) in C:\Users\Usman Bajwa\Desktop\Cloud Tech\OnDemandEncoding\OnDemandEncoding\Models\Azure.cs:line 49

这是我的上传代码。

CloudMediaContext _context = GetContext();

string assetName = Path.GetFileNameWithoutExtension(filePath);
IAsset Asset = _context.Assets.Create(assetName, AssetCreationOptions.None);
Console.Error.Write("Asset Created");
IAssetFile assetFile = Asset.AssetFiles.Create(Path.GetFileName(filePath));
Console.Error.Write(assetFile.Name);
var policy = _context.AccessPolicies.Create(
        assetName,
        TimeSpan.FromDays(20),
        AccessPermissions.Write | AccessPermissions.List);
ILocator locator = _context.Locators.CreateLocator(LocatorType.Sas, Asset, policy);
Console.Error.Write(assetFile.Name);
Console.Error.Write("Uploading File");

assetFile.Upload(filePath);      // Getting Exception at this line

locator.Delete();
policy.Delete();


return assetId = assetFile.Asset.Id;

0 个答案:

没有答案