Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

179
Vistas
How to display image from a binary string in HTML?

I have these type of strings in a mongodb collection See this link: https://controlc.com/089aba3c7

I transform it like this in JavaScript, but then I get a blank image

    item = item.replace("b'", "");
    item = item.substring(0, item.length - 1);
    let url = btoa(item.replace(/\\x([0-9a-f]{2})/ig, function(_, pair) {
      return String.fromCharCode(parseInt(pair, 16));
    }))

    const imageUrl = 'data:image/jpeg;base64,' + url;

If I try to bencode64 in python directly, I get a similar(the start match, but then they do not match) string, but it seems to be the right image.

import base64

example_img = SAME STRING AS ABOVE

m = eval(example_img)
m = base64.b64encode(m)
print(m)

What am I missing... Why don't I get the exact same response in both scenarios?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda