function toBase64(arr) {
arr = new Uint8Array(arr) if it's an ArrayBuffer
return btoa(
arr.reduce((data, byte) => data + String.fromCharCode(byte), '')
);
}
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([img.data], {type : img.contentType})
let img = document.createElement('img').setAttribute('src', URL.createObjectURL(blob))
let container = document.getElementById('container')
container.appendChild(img)
or
let img = document.createElement('img').setAttribute('src', `data:${img.contentType};base64,${img.data}`)
let container = document.getElementById('container')
container.appendChild(img)
but none of it does not seem to work
P.S. In the guide was written i should transform img.data.toString(‘base64’), but it does not work too
Comments
Comment posted by DoloreMentale
@Sean just a typo, it shoud be img.data.data 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: