Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var storageAccount = CloudStorageAccount.Parse(_configuration["MicrosoftAzureStorage:AzureStorageConnectionString"]);
var backOffPeriod = TimeSpan.FromSeconds(2);
var blobClient = storageAccount.CreateCloudBlobClient();
blobClient.DefaultRequestOptions = new BlobRequestOptions()
{
SingleBlobUploadThresholdInBytes = 1024 * 1024, //1MB, the minimum
ParallelOperationThreadCount = 1,
RetryPolicy = new ExponentialRetry(backOffPeriod, maxAttempts: 5),
};
var videoContainer = blobClient.GetContainerReference("videos");
videoContainer.CreateIfNotExists();
var blockBlob = _videoContainer.GetBlockBlobReference(filename);
blockBlob.Properties.ContentType = section.ContentType ?? "application/octet-stream";
storedUrl = blockBlob.Uri.AbsoluteUri;
await blockBlob.UploadFromFileAsync(tempFilename);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment