我用谷歌搜索了这个但找不到答案,但这一定是一个常见问题。这是同样的问题节点请求(读取图像流 - 通过管道返回响应) https://stackoverflow.com/questions/17004990/node-request-read-image-stream-pipe-back-to-response,这是没有答案的。
如何将图像文件作为 Express .send() 响应发送?我需要将 RESTful url 映射到图像 - 但如何发送带有正确标头的二进制文件?例如。,
<img src='/report/378334e22/e33423222' />
Calls...
app.get('/report/:chart_id/:user_id', function (req, res) {
//authenticate user_id, get chart_id obfuscated url
//send image binary with correct headers
});
Express中有一个api。
res.sendFile
app.get('/report/:chart_id/:user_id', function (req, res) {
// res.sendFile(filepath);
});
http://expressjs.com/en/api.html#res.sendFile http://expressjs.com/en/api.html#res.sendFile
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)