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. mysql - 表名稱前綴到底有啥用?2. 怎么php怎么通過數(shù)組顯示sql查詢結(jié)果呢,查詢結(jié)果有多條,如圖。3. 在mybatis使用mysql的ON DUPLICATE KEY UPDATE語法實現(xiàn)存在即更新應(yīng)該使用哪個標(biāo)簽?4. mysql - 數(shù)據(jù)庫表中,兩個表互為外鍵參考如何解決5. 為什么php修改數(shù)據(jù)無法同步到數(shù)據(jù)庫,只是當(dāng)前頁面修改成功?6. 編輯成功不顯示彈窗7. sublime可以用其他編譯器替換嗎?8. tp 6.0 數(shù)據(jù)查詢,求教!9. sql語句 - 如何在mysql中批量添加用戶?10. 哭遼 求大佬解答 控制器的join方法怎么轉(zhuǎn)模型方法
