我需要从本地系统上传文件到azure媒体服务。我已经上传的内容从客户端机器使用HTML5上传程序(浏览器块上传)。参考自,http://gauravmantri.com/2013/02/16/uploading-large-files-in-windows-azure-blob- storage-using-shared-access-signature-html-and-javascript.
现在我需要将上传的文件作为资产从blob存储移动到Azure Media Services并发布。如何实现这一点。有没有人能提供这个过程的例子。
发布于 2015-10-28 15:51:37
从这个链接:Copying an Existing Blob into a Media Services Asset
/// <summary>
/// Creates a new asset and copies blobs from the specifed storage account.
/// </summary>
/// <param name="mediaBlobContainer">The specified blob container.</param>
/// <returns>The new asset.</returns>
static public IAsset CreateAssetFromExistingBlobs(CloudBlobContainer mediaBlobContainer)
{
// Create a new asset.
IAsset asset = _context.Assets.Create("CopyBlob_" + Guid.NewGuid(), AssetCreationOptions.None);
IAccessPolicy writePolicy = _context.AccessPolicies.Create("writePolicy", TimeSpan.FromHours(24), AccessPermissions.Write);
ILocator destinationLocator = _context.Locators.CreateLocator(LocatorType.Sas, asset, writePolicy);
CloudBlobClient destBlobStorage = _destinationStorageAccount.CreateCloudBlobClient();
// Get the asset container URI and Blob copy from mediaContainer to assetContainer.
string destinationContainerName = (new Uri(destinationLocator.Path)).Segments[1];
CloudBlobContainer assetContainer = destBlobStorage.GetContainerReference(destinationContainerName);
if (assetContainer.CreateIfNotExists())
{
assetContainer.SetPermissions(new BlobContainerPermissions
{
PublicAccess = BlobContainerPublicAccessType.Blob
});
}
var blobList = mediaBlobContainer.ListBlobs();
foreach (var sourceBlob in blobList)
{
var assetFile = asset.AssetFiles.Create((sourceBlob as ICloudBlob).Name);
CopyBlob(sourceBlob as ICloudBlob, assetContainer);
assetFile.ContentFileSize = (sourceBlob as ICloudBlob).Properties.Length;
assetFile.Update();
}
destinationLocator.Delete();
writePolicy.Delete();
// Since we copied a set of Smooth Streaming files,
// set the .ism file to be the primary file.
SetISMFileAsPrimary(asset);
return asset;
}
https://stackoverflow.com/questions/33385241
复制相似问题