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. javascript - angularJS指令如何暴露API给外面的controller使用?2. javascript - IOS微信audio标签不能通过touchend播放3. [前端求职必看]前端开发面试题与答案精选_大纲4. docker不显示端口映射呢?5. mysql - 数据库建表方面的问题?6. javascript - web端请求一个正在被修改的文件会怎么样?7. docker镜像push报错8. docker start -a dockername 老是卡住,什么情况?9. javascript - react,获取radio的值出错10. docker images显示的镜像过多,狗眼被亮瞎了,怎么办?
