Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

186
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda