Display png file from base64

Working with Node.js as server side and MSSQL as the database.
I have a png file stored as a base64 in a database table. How do I display that as an image? I know you have to bind it to an image and decode it, just don’t know the correct syntax for the code.

Thanks.

How is it stored in the db?
Is it stored including the data:image/png;base64,YOUR_BASE64_IMAGE_STRING

It is stored as just the string.

Try something like:

dmx-bind:src="'data:image/png;base64,' + your_dynamic_string_value"
2 Likes

That was it!
So… What if it was a pdf? I know how to embed a pdf file in html, what prefix do I add to it?

Maybe check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs

2 Likes

Thanks! Will do.