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. mac连接阿里云docker集群,已经卡了2天了,求问?2. docker绑定了nginx端口 外部访问不到3. docker内创建jenkins访问另一个容器下的服务器问题4. docker gitlab 如何git clone?5. python - 使用pandas的resample报错6. angular.js - angular内容过长展开收起效果7. javascript - 使用vue做个抽奖问题8. gulp-ruby-sass编译出来的文件有错9. docker start -a dockername 老是卡住,什么情况?10. mysql优化 - mysql 一张表如果不能确保字段列长度一致,是不是就不需要用到char。

网公网安备