Skip to content

Instantly share code, notes, and snippets.

@scattered-code
Last active September 21, 2020 02:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scattered-code/acb74cb08bb0834b76803546891c9574 to your computer and use it in GitHub Desktop.
Save scattered-code/acb74cb08bb0834b76803546891c9574 to your computer and use it in GitHub Desktop.
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