public async Task <Asset> CreateAsset(string storageAccount, string assetName, string assetDescription, string assetAlternateId, string fileName) { if (string.IsNullOrEmpty(assetName)) { assetName = Path.GetFileNameWithoutExtension(fileName); } StorageBlobClient blobClient = new StorageBlobClient(this.MediaAccount, storageAccount); string sourceContainer = Constant.Storage.Blob.WorkflowContainerName; string sourceUrl = blobClient.GetDownloadUrl(sourceContainer, fileName); Asset asset = CreateAsset(storageAccount, assetName, assetDescription, assetAlternateId); CloudBlockBlob assetBlob = blobClient.GetBlockBlob(asset.Container, null, fileName); await assetBlob.StartCopyAsync(new Uri(sourceUrl)); return(asset); }
public Asset CreateAsset(string storageAccount, string assetName, CloudBlockBlob sourceFile) { if (string.IsNullOrEmpty(assetName)) { assetName = Path.GetFileNameWithoutExtension(sourceFile.Name); } Asset asset = CreateAsset(storageAccount, assetName); StorageBlobClient blobClient = new StorageBlobClient(this.MediaAccount, storageAccount); CloudBlockBlob assetFile = blobClient.GetBlockBlob(asset.Container, null, sourceFile.Name); assetFile.UploadFromStream(sourceFile.OpenRead()); assetFile.Properties.ContentType = sourceFile.Properties.ContentType; assetFile.SetProperties(); return(asset); }
public Asset CreateAsset(StorageBlobClient sourceBlobClient, StorageBlobClient assetBlobClient, string storageAccount, string assetName, string assetDescription, string assetAlternateId, string sourceContainer, string[] fileNames) { List <Task> copyTasks = new List <Task>(); if (string.IsNullOrEmpty(assetName)) { assetName = Path.GetFileNameWithoutExtension(fileNames[0]); } Asset asset = CreateAsset(storageAccount, assetName, assetDescription, assetAlternateId); foreach (string fileName in fileNames) { string sourceUrl = sourceBlobClient.GetDownloadUrl(sourceContainer, fileName, false); CloudBlockBlob assetBlob = assetBlobClient.GetBlockBlob(asset.Container, null, fileName); Task copyTask = assetBlob.StartCopyAsync(new Uri(sourceUrl)); copyTasks.Add(copyTask); } Task.WaitAll(copyTasks.ToArray()); return(asset); }