所有PDF文件都保存在服务器的文件系统中,如何使文件可以在客户端下载。
例如:
app.use('/pdfDownload', function(req, res){
var pathToTheFile = req.body.fileName;
readFile(pathToTheFile, function(data){
//code to make the data to be downloadable;
});
});
是提出的要求
function readFile(pathToTheFile, cb){
var fs = require('fs');
fs.readFile(pathToTheFile, function(err, data){
//how to make the file fetched to be downloadable in the client requested
//cb(data);
});
}