file-download.js 297 B

123456789
  1. var fs = require("fs");
  2. var path = require("path");
  3. const filePath = path.resolve(__dirname, '..' + path.sep + 'upload');
  4. module.exports = function(request, response) {
  5. var fpath = filePath + path.sep + request.query.path;
  6. return fs.createReadStream(fpath);//得到文件输入流
  7. };