-1

The binary image data is stored in mongodb collection as shown below

image:Binary('XXXXXXXXXXX...', 0)

when I am trying to display it in html

<div > <img src="data:image/png;base64,{{person.image}}"/></div>

It gives me this error when executing:

net::ERR_UNKNOWN_URL_SCHEME png;base64,[object Object]:1

I didn't convert the binary data to base64

R. Richards
  • 24,603
  • 10
  • 64
  • 64
  • [object Object] Looks a bit off.. what do you see when you just do {{person.image | json}} somewhere in the template? – MikeOne Oct 07 '21 at 21:46

1 Answers1

0

Binary is class that has only the default toString method.

To get the data URL string you will probably need to use the Binary class getData method to return a byte array, and then convert that to a base64 string as described here: https://stackoverflow.com/a/33552306/2282634

Joe
  • 25,000
  • 3
  • 22
  • 44