Skip to content

Instantly share code, notes, and snippets.

@takashi-uesaka
Last active September 3, 2015 14:39
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 takashi-uesaka/3196e8ffbdcd3417d5d5 to your computer and use it in GitHub Desktop.
Save takashi-uesaka/3196e8ffbdcd3417d5d5 to your computer and use it in GitHub Desktop.
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