Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

394
Views
Cómo mostrar la imagen en html usando el manillar proviene de MYSQL como blob

Quiero mostrar la imagen de la tienda como blob en HTML usando barras de control

Así es como consulto la imagen en app.js

 app.get('/',(request,response)=>{ db.query('select Image from pictures LIMIT 3', function(err, result) { let base64String = result.toString("base64"); //var image = '<img src="'+base64String+'" class="denr-logo">'; response.render('NPPNP',{images:base64String}); //response.send(base64String); });

Varios sitios se convirtieron a cadenas base64 y las combinaron con etiquetas y 'data:image;base64,xxx=='

En realidad, investigo varios métodos, ejemplos, pero no puedo entender cómo lo hacen.

Cuando consola.log el base64String , muestra [objeto Objeto] y cuando lo paso al HTML nada...

Usando manillares

 {{#each images}} {{this.Image}} {{/each}}

Este es el resultado antes de convertir a base64 .

 [{"Image":{"type":"Buffer","data":[137,80,78,71,13,10,26,10,0,0,0,13............
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Primero necesitarás obtener los valores binarios usando `result[0].Image' como podemos ver en tu resultado

Segundo convertir binarios a base64 esto le dará como este iVBORw0KGgoAAAANSUhEU==

 var base = Buffer.from(result[0].Image); var conversion = base.toString('base64'); var send = '<img src="data:image/png;base64,'+conversion+'" alt="something familiar"/>'; response.send(send);

Podría solucionar su problema, lo hice por mi cuenta y funcionó

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!