Node Express sending image files as API response

后端 未结 2 2014
鱼传尺愫
鱼传尺愫 2020-12-08 00:14

I Googled this but couldn\'t find an answer but it must be a common problem. This is the same question as Node request (read image stream - pipe back to response), which is

2条回答
  •  清歌不尽
    2020-12-08 00:53

    There is an api in Express.

    res.sendFile

    app.get('/report/:chart_id/:user_id', function (req, res) {
        // res.sendFile(filepath);
    });
    

    http://expressjs.com/en/api.html#res.sendFile

提交回复
热议问题