1

I am storing files in SQL Server database as filestream datatype and it returns a blob. I am using nodejs with express. Is there a way to convert these blobs to images and send it to my ejs template using nodejs and express?

namko
  • 627
  • 1
  • 14
  • 27
  • Does this answer your question? [Node : how to convert from varbinary to image of SQL Server datatype](https://stackoverflow.com/questions/45473672/node-how-to-convert-from-varbinary-to-image-of-sql-server-datatype) – FoggyDay Mar 22 '20 at 03:25

1 Answers1

1

const blobToImage = (blob) => {
  return new Promise(resolve => {
    const url = URL.createObjectURL(blob)
    let img = new Image()
    img.onload = () => {
      URL.revokeObjectURL(url)
      resolve(img)
    }
    img.src = url
  })
}
kira
  • 26
  • 4