nodejs download file from server to local
2015-01-27 18:11
507 查看
app.get('/dnExcelToLocal',function(req,res){
var path = require('path');
var fs = require('fs');
var file = '/Users/xxx/Documents/projName/xlsx/armor.xlsx';
var filename = path.basename(file);
res.setHeader('Content-disposition', 'attachment; filename=' + filename);
var fileStream = fs.createReadStream(file);
fileStream.pipe(res);
});
示例中是自己的需求,将xlsx文件 下载到本地.
var path = require('path');
var fs = require('fs');
var file = '/Users/xxx/Documents/projName/xlsx/armor.xlsx';
var filename = path.basename(file);
res.setHeader('Content-disposition', 'attachment; filename=' + filename);
var fileStream = fs.createReadStream(file);
fileStream.pipe(res);
});
示例中是自己的需求,将xlsx文件 下载到本地.
相关文章推荐
- How to download a file with Node.js?
- 启动hadoop报ERROR org.apache.hadoop.hdfs.server.namenode.FSImage: Failed to load image from FSImageFile
- put file from local to remote server
- putty use on Windows: transfer file from local computer to server
- How to download a file with Node.js?
- Internet Explorer Cannot Download Office Documents from an IIS Server When Content Expiration Is Set to Expire Immediately
- How to open/read/write a local file from an applet
- How to transfer image file to server from android
- [Whole Web] [Node.js] Using npm run to launch local scripts
- How To Install Node.js on an Ubuntu 14.04 server
- Java to download a file from internet
- Build File Server With NodeJS
- 如何解决"unable to get project file from web server"问题
- Using CURL to download a remote file from a valid URL in c++
- How to trigger a scheduled task of server from local machine
- Copy file to / from server via SCP command
- STOPPING server from pid file /usr/local/mysql/data/hello.pid
- ubuntu 复制文件到xp (How i can copy file from server(OS:ubuntu 10.04) to my PC
- [Server Running] [Node.js, PM2] Using PM2 To Keep Your Node Apps Alive
- Node.js howto: make asynchronous callback from thread