Skip to content

Instantly share code, notes, and snippets.

@nmackenzie
Last active December 24, 2015 08:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nmackenzie/6774378 to your computer and use it in GitHub Desktop.
Save nmackenzie/6774378 to your computer and use it in GitHub Desktop.
private List<String> GetDownloadAssetSasList(IJob job)
{
IAsset assetToDownload = job.OutputMediaAssets[0];
IAccessPolicy sharedAccessPolicy = context.AccessPolicies.Create(
"DownloadFor7DaysPolicy",
TimeSpan.FromDays(7),
AccessPermissions.Read
);
ILocator locator = context.Locators.CreateLocator(
LocatorType.Sas,
assetToDownload,
sharedAccessPolicy,
DateTime.UtcNow.AddMinutes(-5) // In case of clock drift
);
List<String> downloadAssetSasList = new List<String>();
foreach (IAssetFile assetFile in assetToDownload.AssetFiles)
{
UriBuilder uriBuilder = new UriBuilder(locator.Path);
uriBuilder.Path += "/" + assetFile.Name;
downloadAssetSasList.Add(uriBuilder.Uri.AbsoluteUri);
}
return downloadAssetSasList;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment