node.js - nodejs如何发送请求excel文件并下载
问题描述
问题解答
回答1:res.download(path [, filename] [, fn]) http://expressjs.com/en/api.h...Transfers the file at path as an “attachment”. Typically, browsers will prompt the user for download. By default, the Content-Disposition header “filename=” parameter is path (this typically appears in the browser dialog). Override this default with the filename parameter.
When an error ocurrs or transfer is complete, the method calls the optional callback function fn. This method uses res.sendFile() to transfer the file.
res.download(’/report-12345.pdf’);res.download(’/report-12345.pdf’, ’report.pdf’);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. }});
相关文章:
1. php laravel框架模型作用域2. java - 想在微信公众号下自定义菜单内搭建一个论坛,用到什么技术?3. css - 关于input标签disabled问题4. phpstudy v8 为什么网站刷新后会出现403错误?5. 微信$data =file_get_contents(’php://input’)取不到数据,抓包6. phpStudy2017轻巧版mysql无法启动7. Java中的BufferedImage在Android之中如何对应?8. redis - 腾讯的QQ平台如何维护庞大的在线用户列表?9. Spring数据mongodb审核不起作用(Java配置)10. 怎么让其他pc访问本地的phpstudy编写的网页
