Last active
September 3, 2015 14:39
-
-
Save takashi-uesaka/3196e8ffbdcd3417d5d5 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
var _mediaServicesAccountName = "<アカウント名>"; | |
var _mediaServicesAccountKey = "<アカウントキー>"; | |
var _cachedCredentials = new MediaServicesCredentials( | |
_mediaServicesAccountName, | |
_mediaServicesAccountKey); | |
var _context = new CloudMediaContext(_cachedCredentials); | |
var file = "BigBuckBunny.mp4"; | |
var assetName = Path.GetFileNameWithoutExtension(file); | |
// ポイントはここ。アセット作るときにオプションでStorageEncryptedを指定するだけ! | |
IAsset inputAsset = _context.Assets.Create(assetName, AssetCreationOptions.StorageEncrypted); | |
var assetFile = inputAsset.AssetFiles.Create(Path.GetFileName(file)); | |
var policy = _context.AccessPolicies.Create( | |
assetName, | |
TimeSpan.FromDays(30), | |
AccessPermissions.Write | AccessPermissions.List); | |
var locator = _context.Locators.CreateLocator(LocatorType.Sas, inputAsset, policy); | |
assetFile.Upload(file); | |
locator.Delete(); | |
policy.Delete(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment