Exemplo n.º 1
0
        public async Task <string> UploadImageAsBlob(IFormFile file)
        {
            if (file != null && (file.ContentType.StartsWith("image") || file.ContentType.StartsWith("audio") || file.ContentType.StartsWith("video")))
            {
                _stream = file.OpenReadStream();
                string extension = Path.GetExtension(file.FileName);
                _blockBlob = _container.GetBlockBlobReference(FileNameHelper.CreateFileName(extension));
                await _blockBlob.UploadFromStreamAsync(_stream);

                return(_blockBlob.Name);
            }
            return(null);
        }