如何解决如何使用节点js和处理程序栏将BLOB对象从mysql DB解码为png图像以显示在目录中
我在尝试从数据库获取此图像时遇到了一些麻烦,该BLOB文件是PNG。
我正在使用此js代码读取DB BLOB,但如何使用它在HTML中呈现
router.get('/productos/ofertas',async(req,res) => {
const ofer = await pool.query('SELECT art_id,clave,claveAlterna,descripcion,precio1,caracteristicas from articulo where art_id between 10 and 25');
const img = await pool.query('SELECT imagen FROM imagen where img_id =20');
console.log(img[0])
res.render('links/ofertas',{ofer,img});
});
然后我在控制台中得到它
我用这样的处理程序栏渲染
<div class="container p-3">
<div class="row">
{{#each ofer}}
<div class="card" style="width: 18rem;">
{{#each img}}
<img src="" class="card-img-top" alt="data:image/png;base64,{{imagen}}"> I WANT TO LOAD THE IMAGES HERE FOR EACH ITEM
{{/each}}
<div class="card-body">
<h5 class="card-title">{{clave}}</h5>
<p class="card-text">{{descripcion}}</p>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item">{{claveAlterna}}</li>
<li class="list-group-item">{{caracteristicas}}</li>
<li class="list-group-item">Vestibulum at eros</li>
</ul>
<div class="card-body">
<a href="#" class="card-link">Card link</a>
<a href="#" class="card-link">Another link</a>
</div>
</div>
{{else}}
<div class="col-md4 mx-auto">
<div class="card card-body text-center">
<p>NO HAY OFERTAS POR AHORA,REVISA NUESTROS PRODUCTOS!</p>
<a href="/links/productos">Productos!</a>
</div>
</div>
{{/each}}
</div>
</div>
<footer class="container py-5">
<div class="row">
<div class="col-12 col-md">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" class="d-block mb-2" role="img" viewBox="0 0 24 24" focusable="false"><title>Product</title><circle cx="12" cy="12" r="10"/><path d="M14.31 8l5.74 9.94M9.69 8h11.48M7.38 12l5.74-9.94M9.69 16L3.95 6.06M14.31 16H2.83m13.79-4l-5.74 9.94"/></svg>
<small class="d-block mb-3 text-muted">© 2017-2020</small>
</div>
</div>
在img src中
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。