You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Goal: Upload multiple files while still having a "progress" updates that can tell the user how long it still takes. Uploading files from a client computer which cannot be trusted with API keys/secrets so retrieving SaSLocator via API.
Problem: File does seem to upload because it takes long, azure blob storage shows successful upload but nothing is shown after it is done, see screenshots in SO thread.
Steps to reproduce:
Use below code, acting as the server side of any API:
public async Task<VideoUploadModel> GetSasLocator(string filename)
{
var assetName = filename + DateTime.UtcNow;
IAsset asset = await _context.Assets.CreateAsync(assetName, AssetCreationOptions.None, CancellationToken.None);
IAccessPolicy accessPolicy = _context.AccessPolicies.Create(assetName, TimeSpan.FromMinutes(10),
AccessPermissions.Write);
var locator = _context.Locators.CreateLocator(LocatorType.Sas, asset, accessPolicy);
var blobUri = new UriBuilder(locator.Path);
blobUri.Path += "/" + filename;
var model = new VideoUploadModel()
{
Filename = filename,
AssetName = assetName,
SasLocator = blobUri.Uri.AbsoluteUri,
AssetId = asset.Id
};
return model;
}
And below code acting as a Client:
public async Task UploadVideoFileToBlobStorage(string[] files, string sasLocator, CancellationToken cancellationToken)
{
var blobUri = new Uri(sasLocator);
var sasCredentials = new StorageCredentials(blobUri.Query);
//var blob = new CloudBlockBlob(new Uri(blobUri.GetComponents(UriComponents.SchemeAndServer | UriComponents.Path, UriFormat.UriEscaped)), sasCredentials);
var blobClient = new CloudBlobClient(new Uri(blobUri.GetComponents(UriComponents.SchemeAndServer | UriComponents.Path, UriFormat.UriEscaped)), sasCredentials);
var blobTransferClient = new BlobTransferClient(TimeSpan.FromMinutes(1))
{
NumberOfConcurrentTransfers = 2,
ParallelTransferThreadCount = 2
};
//register events
blobTransferClient.TransferProgressChanged += BlobTransferClient_TransferProgressChanged;
//files
var uploadTasks = new List<Task>();
foreach (var filePath in files)
{
await blobTransferClient.UploadBlob(blobUri, filePath, new FileEncryption(), cancellationToken, blobClient, new NoRetry());
}
}
What am I doing wrong?
And while we are added, what is FileEncryption used for and why is it required?
The text was updated successfully, but these errors were encountered:
Hi,
Best is to read this SO: https://stackoverflow.com/questions/50626180/upload-to-azure-media-services-blob-storage-with-saslocator.
Goal: Upload multiple files while still having a "progress" updates that can tell the user how long it still takes. Uploading files from a client computer which cannot be trusted with API keys/secrets so retrieving SaSLocator via API.
Problem: File does seem to upload because it takes long, azure blob storage shows successful upload but nothing is shown after it is done, see screenshots in SO thread.
Steps to reproduce:
Use below code, acting as the server side of any API:
And below code acting as a Client:
What am I doing wrong?
And while we are added, what is FileEncryption used for and why is it required?
The text was updated successfully, but these errors were encountered: