【问题标题】:res.attachment(). Resource interpreted as Document but transferred with MIME type text/csv: "http://localhost:3000/post"res.attachment()。资源解释为 Document,但使用 MIME 类型 text/csv 传输:“http://localhost:3000/post”
【发布时间】:2019-04-04 18:03:34
【问题描述】:

试图触发文件下载。

res.attachment('./public/uploads/name-1540993539785.csv')

文件已下载,但其内容只是“uploads/name-1540995323357.csv”而不是真实数据。

在控制台中收到警告:

资源解释为文档,但使用 MIME 类型 text/csv 传输:“http://localhost:3000/post”。

【问题讨论】:

    标签: node.js express mime-types


    【解决方案1】:

    你可能想要的是res.download

    res.attachment 只是将 Content-Disposition 标头字段设置为“附件”,并将 Content-Type 设置为确定的类型。 res.download 也会发送有问题的文件。

    【讨论】:

      猜你喜欢
      • 2014-04-20
      • 1970-01-01
      • 2016-03-30
      • 2017-03-19
      • 1970-01-01
      • 2013-04-12
      • 2013-05-26
      • 2017-08-01
      相关资源
      最近更新 更多