We're using ASP.NET MVC 4 to allow users to upload video and audio through our website. I would like to use Azure Media Service as the back-end for this.
While following Azure's tutorial, the issue I've run into is that the Azure Media Services SDK doesn't appear to allow uploading a raw stream of data. Instead, the only upload method I could find uses a path string argument.
I would like to avoid saving the file to disk (it's already streamed to disk by default), and be able to stream the request posted file right through to Azure.
Here is my code thus far:
public void SaveMedia(string fileName, System.IO.Stream stream)
{
CloudMediaContext mediaCloud = new CloudMediaContext("account", "key");
AssetCreationOptions assetOptions = new AssetCreationOptions();
var asset = mediaCloud.Assets.Create(fileName, assetOptions);
var assetFile = asset.AssetFiles.Create(fileName);
var accessPolicy = mediaCloud.AccessPolicies.Create(fileName, TimeSpan.FromDays(3), AccessPermissions.Write | AccessPermissions.List);
var locator = mediaCloud.Locators.CreateLocator(LocatorType.Sas, asset, accessPolicy);
assetFile.Upload("????????????");
locator.Delete();
accessPolicy.Delete();
}
How does one accomplish this? Would this conflict with any "best practices" for handling uploads using ASP.NET MVC 4 and Azure Media Services?