简体   繁体   中英

Using express how to send blob object as response

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?

A bit indirect but this will work:

res.type(blob.type)
blob.arrayBuffer().then((buf) => {
    res.send(Buffer.from(buf))
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM