Node Express将图像文件发送为API响应
我谷歌search,但无法find答案,但它必须是一个共同的问题。 这与节点请求(读取图像stream – pipe道回到响应)相同的问题,这是没有答案。
如何将图像文件作为Express .send()响应发送? 我需要将RESTful url映射到图像 – 但是如何将正确的头文件发送给二进制文件? 例如,
<img src='/report/378334e22/e33423222' />
电话…
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); });
- passport.js passport.initialize()中间件未被使用
- node.js + express 3 + socket.io =发送后无法设置标题
- NodeJS / Express app.use序列和用法
- 在Express中使用`jade`模板引擎时呈现`html`
- nodejs为所有请求执行通用操作
- Express + Node:与原始文件相比,通过response.download()下载的文件大小不同
- 节点101:未定义app.use ReferenceError
- 使用ExpressJS POST请求是空的
- 使用Passport JS的自定义策略Oauthauthentication