【问题标题】:download file and send message as response in Postman下载文件并在 Postman 中发送消息作为响应
【发布时间】:2020-08-28 05:44:43
【问题描述】:

是否可以同时通过Postman下载文件和发送成功消息?

这是我的代码:

res.download(file);
res.status(200).json({ 'result': 'file downloaded!' });

【问题讨论】:

    标签: express postman


    【解决方案1】:

    只是一个提示,根据 express doc:http://expressjs.com/en/api.html#res.downloadres.download 允许回调,所以你有没有尝试在那里做点什么?

    res.download('/report-12345.pdf', 'report.pdf', function (err) {
      if (err) {
        // Handle error, but keep in mind the response may be partially-sent
        // so check res.headersSent
      } else {
        // decrement a download credit, etc.
      }
    })
    

    【讨论】:

      猜你喜欢
      • 2021-03-20
      • 2018-01-14
      • 2017-12-05
      • 2021-01-04
      • 2020-06-25
      • 1970-01-01
      • 2012-04-20
      • 1970-01-01
      • 2019-05-14
      相关资源
      最近更新 更多