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. 为什么我ping不通我的docker容器呢???2. mac里的docker如何命令行开启呢?3. java - xml 传输数据如何处理更好4. javascript - h5上的手机号默认没有识别5. python - 类 对象 函数后面的参数问题,勉强看懂但是要自己写出来就感觉很困难6. javascript - 想让图片上那个块,在增加块的宽度的时候向右边移动,而不是向左边移动。需要怎么解决?7. mysql - 要取出数据库中按某字段排序后的前10,20,30条数据要怎么做?8. 求大神帮我看看是哪里写错了 感谢细心解答9. Python Selenium WebDriver如何刷新当前页面10. 用tp5框架写sql语句

网公网安备