最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Using express how to send blob object as response - Stack Overflow

programmeradmin2浏览0评论

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?

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?

Share Improve this question asked Oct 5, 2018 at 11:55 NowfalNowfal 931 gold badge1 silver badge4 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 20

A bit indirect but this will work:

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

评论列表(0)

  1. 暂无评论