Last active
December 24, 2015 08:59
-
-
Save nmackenzie/6774378 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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