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

178
Views
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
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!