Using express how to send blob object as response
Asked Answered
F

1

9

Im using express and truevault to store images in my server. From the truevault api I get a blob object that looks like this

{ blob:
   Blob {
     [Symbol(type)]: 'image/png',
     [Symbol(buffer)]: <Buffer 89  ... > },
  contentType: 'image/png',
  fileName: 'image.png' }
}

How do I send this blob in the response object?

Florist answered 5/10, 2018 at 11:55 Comment(0)
H
20

A bit indirect but this will work:

res.type(blob.type)
blob.arrayBuffer().then((buf) => {
    res.send(Buffer.from(buf))
}
Handmade answered 4/9, 2019 at 22:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.