[英]How can I convert blob image from database to html image src
I have a blob field in the database which stores image blob.我在存储图像 blob 的数据库中有一个 blob 字段。 I want to convert this to an image in the html image src tag.
我想将其转换为 html 图像 src 标签中的图像。 How can this be done, i am using ASP.NET MVC c# as my backend.
如何做到这一点,我使用 ASP.NET MVC c# 作为我的后端。
One way is to convert it to Base64String.一种方法是将其转换为 Base64String。 First convert it to ByteArray then you can get Base64String.
首先将其转换为ByteArray,然后您可以获得Base64String。 for example:
例如:
var imgUrl = $"data:{imageType};base64,{Convert.ToBase64String(buffer)}";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.