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

230
Views
¿Cómo usar una cadena binaria para mostrar una imagen en una etiqueta de imagen?

Subo una imagen y la envío al back-end con este código:

 const formData = new FormData(); formData.append('file', event.target.files[0]);

Luego obtengo la carga útil de esta imagen desde el back-end que tiene un tipo de cadena binaria. Quiero mostrar la imagen y ya probé estas soluciones:

  1. Convierte a un Blob y úsalo así
 const blob = new Blob([payload]); <img src="data:image/png;base64,'+ blob" />
  1. Use FileReader y readAsDataURL
 var reader1 = new FileReader(); reader1.readAsDataURL(new Blob([payload])); reader1.onload = function () { let paar: any = document.getElementById('imagePreview'); paar.src = reader.result; };
  1. createObjectURL Blob
 const blob = new Blob([payload]); const url = URL.createObjectURL(blob); const img: any = document.getElementById('imagePreview'); img.src = url; img.onload = (e) => URL.revokeObjectURL(url);

Aquí la URL se ve así: blob:http://localhost:3000/92540eea-6f01-46db-86d0-14491a8b6abf y no funciona, porque debería verse así: "data://base64".

¿Cómo puedo mostrar esta imagen?

about 4 years ago · Juan Pablo Isaza
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!