Solution 1 :

If you have the same issue, just check wether you use this guide:
if so, just do the same as here:

function toBase64(arr) {
   arr = new Uint8Array(arr) if it's an ArrayBuffer
   return btoa(
      arr.reduce((data, byte) => data + String.fromCharCode(byte), '')

Problem :

I store images im mongoDB like this:

img: {
  contentType: "image/png"
  data: {
    data: Array(135239),
    type: "Buffer"

Then i got them on frontend and trying to use in html img tag, but there are no pictures
I have tried to transform the data to

let blob = new Blob([], {type : img.contentType})
let img = document.createElement('img').setAttribute('src', URL.createObjectURL(blob))
let container = document.getElementById('container')


let img = document.createElement('img').setAttribute('src', `data:${img.contentType};base64,${}`)
let container = document.getElementById('container')

but none of it does not seem to work

P.S. In the guide was written i should transform‘base64’), but it does not work too


Comment posted by DoloreMentale

@Sean just a typo, it shoud be then

Comment posted by Convert Blob to image url and use in image src to display image

Does this answer your question?

Comment posted by DoloreMentale

@SalmenBejaoui unfortunately nope, but i found another one post thanks to yours

Comment posted by add context around the link

A link to a solution is welcome, but please ensure your answer is useful without it: