User-862431657 posted
I am uploading a image to Azure Blob Storage.It creates container but the container doesnot contain any blobs though it doesnot show any errors.My code is like below.Please let me know what could be wrong?
public CloudBlockBlob UploadBlob(IFormFile file)
{
string blobName = Path.GetFileName(ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"'));
_container.CreateIfNotExistsAsync();
_container.SetPermissionsAsync(new BlobContainerPermissions
{
PublicAccess = BlobContainerPublicAccessType.Blob
});
//Get reference to a blob
_blockBlob = _container.GetBlockBlobReference(blobName);
using (var fileStream = file.OpenReadStream())
{
_blockBlob.UploadFromStreamAsync(fileStream);
}
var blobsName = _blockBlob.Uri.ToString();
return _blockBlob;
}