本文整理汇总了C#中IAsset.Update方法的典型用法代码示例。如果您正苦于以下问题:C# IAsset.Update方法的具体用法?C# IAsset.Update怎么用?C# IAsset.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAsset
的用法示例。
在下文中一共展示了IAsset.Update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessReplica
private void ProcessReplica()
{
//1. Create Target Asset
targetAsset = targetMediaContext.Assets.Create(triggerAsset.Name, AssetCreationOptions.None);
IAccessPolicy writePolicy = targetMediaContext.AccessPolicies.Create("writePolicy_" + targetAsset.Name, TimeSpan.FromMinutes(120), AccessPermissions.Write);
ILocator destinationLocator = targetMediaContext.Locators.CreateLocator(LocatorType.Sas, targetAsset, writePolicy);
//2. Copy each File fron Origin to Target
//2.1 Target Asset Storage
CloudBlobClient targetAssetClient = targetStorageAccount.CreateCloudBlobClient();
CloudBlobContainer targetAssetContainer = targetAssetClient.GetContainerReference(targetAsset.Uri.Segments[1]);
//2.2 Trigger (origen) Asset Storage
CloudBlobClient triggerAssetClient = triggerStorageAccount.CreateCloudBlobClient();
CloudBlobContainer triggerAssetContainer = triggerAssetClient.GetContainerReference(triggerAsset.Uri.Segments[1]);
//3. Start Copy all Files
foreach (IAssetFile triggerAssetFile in triggerAsset.AssetFiles)
{
//if (triggerAssetFile.Name.ToLower().EndsWith(".mp4"))
{
string triggerAssetFileUrl = triggerAsset.Uri.AbsoluteUri + "/" + triggerAssetFile.Name;
string targetAssetFileUrl = targetAsset.Uri.AbsoluteUri + "/" + triggerAssetFile.Name;
startCopyBlob(triggerAssetContainer, triggerAssetFileUrl, targetAssetContainer, targetAssetFileUrl);
}
}
//4. Wait all copy process finish
CloudBlockBlob blobStatusCheck;
bool waitLighTrafic = true;
while (waitLighTrafic)
{
waitLighTrafic = false;
foreach (IAssetFile triggerAssetFile in triggerAsset.AssetFiles)
{
// if (triggerAssetFile.Name.ToLower().EndsWith(".mp4"))
{
blobStatusCheck = (CloudBlockBlob)targetAssetContainer.GetBlobReferenceFromServer(triggerAssetFile.Name);
Trace.TraceInformation("{0} copy {1} bytes of {2} Bytes", triggerAssetFile.Name, blobStatusCheck.CopyState.BytesCopied, blobStatusCheck.CopyState.TotalBytes);
waitLighTrafic = (blobStatusCheck.CopyState.Status == CopyStatus.Pending);
}
}
Task.Delay(TimeSpan.FromSeconds(10d)).Wait();
}
foreach (IAssetFile triggerAssetFile in triggerAsset.AssetFiles)
{
//if (triggerAssetFile.Name.ToLower().EndsWith(".mp4"))
{
//Add the xFile to Asset
var assetFile = targetAsset.AssetFiles.Create(triggerAssetFile.Name);
}
}
destinationLocator.Delete();
writePolicy.Delete();
targetAsset.Update();
}
示例2: CreateCommonTypeContentKey
static public IContentKey CreateCommonTypeContentKey(IAsset asset, CloudMediaContext _context, Guid keyId, byte[] contentKey)
{
IContentKey key = _context.ContentKeys.Create(
keyId,
contentKey,
"ContentKey CENC",
ContentKeyType.CommonEncryption);
// Associate the key with the asset.
asset.ContentKeys.Add(key);
asset.Update();
return key;
}