c# - How can I convert blob image from database to html image src
问题描述
I have a blob field in the database which stores image blob. I want to convert this to an image in the html image src tag. How can this be done, i am using ASP.NET MVC c# as my backend.
解决方案
One way is to convert it to Base64String. First convert it to ByteArray then you can get Base64String. for example:
var imgUrl = $"data:{imageType};base64,{Convert.ToBase64String(buffer)}";
推荐阅读
- python - 如何在 python flask api 应用程序启动时处理 FlaskInjector 错误?
- c - 这个函数可以在c中将二进制转换为整数吗
- c - 似乎 disable_irq 不能真正屏蔽中断
- python - Django 验证错误引发但未显示在购物车应用程序中
- javascript - 在 Loopback 模型中将数据推送到数组中
- angular - 由于未及时设置变量而导致的未定义值
- javascript - 在 React Js 中处理多个上传图像 + 将其发送到服务器
- php - 如何在 laravel 中使用 created_at 进行分组
- python - 从熊猫数据框中另一列的每个唯一值的范围内的列中找到一个固定值
- reactjs - React Styled-Components 传递道具问题