node.js - nodejs如何發(fā)送請求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. }});
相關(guān)文章:
1. docker-machine添加一個已有的docker主機(jī)問題2. angular.js - 為什么給 Angular 指令綁定事件無法生效3. 為什么我ping不通我的docker容器呢???4. golang - 用IDE看docker源碼時的小問題5. html5 - 使用angular中,圖片上傳功能中選擇多張圖片是怎么實現(xiàn)的?有什么好的思路嗎?6. docker - 各位電腦上有多少個容器啊?容器一多,自己都搞混了,咋辦呢?7. mysql - 詳細(xì)論述聯(lián)表查詢與分步查詢的優(yōu)缺點8. mysql - 求SQL語句9. php如何獲取訪問者路由器的mac地址10. PHP注冊功能
