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. 編輯成功不顯示彈窗2. 哭遼 求大佬解答 控制器的join方法怎么轉模型方法3. Navicat for mysql 中以json格式儲存的數據存在大量反斜杠,如何去除?4. mysql - 數據庫表中,兩個表互為外鍵參考如何解決5. mysql儲存json錯誤6. mysql - 怎么生成這個sql表?7. mysql - 表名稱前綴到底有啥用?8. sql語句 - 如何在mysql中批量添加用戶?9. 在mybatis使用mysql的ON DUPLICATE KEY UPDATE語法實現存在即更新應該使用哪個標簽?10. 怎么php怎么通過數組顯示sql查詢結果呢,查詢結果有多條,如圖。
