I would like to asynchronously upload a single file via an ASP.NET Forms C# project to Azure Blob storage and then delete the file from the local storage once the upload is completed. The files will be large hence why I don't want to leave the user waiting for the operation to complete.
My code seems to work but I'm wondering if there is a better or best practise way of achieving this?
public async Task<string> SaveImageToBLOBStorageAndDelFromWebSpace(ImageDetails objImageDetail)
{
var container = _client.GetContainerReference(objImageDetail.BlobContainer);
var blob = container.GetBlockBlobReference(objImageDetail.FileName);
await blob.UploadFromFileAsync(HttpContext.Current.Server.MapPath(objImageDetail.FullPathIncFileName)).ConfigureAwait(false);
try
{
File.Delete(System.Web.Hosting.HostingEnvironment.MapPath(objImageDetail.FullPathIncFileName));
}
catch (Exception e)
{
throw;
}
return objImageDetail.FileName;
}