fs.stat(file_path, function (err, stats) {
let r = fs.createReadStream(file_path, {flags: 'r'});
response.writeHead(200, {
'Content-Type': mime,
"Content-Length": stats.size,
'Content-Disposition': 'attachment; filename=' + file_name
});
r.pipe(response);
r.on('end', function () {
r.destroy();
response.end();
});
r.on('error', function (error) {
logger.error('->>>download', error);
r.destroy();
response.end();
});
});
错误日志中没有任何内容 但在/ proc / pid / fd中,句柄越来越多
一些hanle数据
72 -> /home/ec2-user/gm/uploads/respatch_scorequest_android_a.zip
73 -> /home/ec2-user/gm/uploads/cpatch_scorequest_android_a.zip
74 -> /home/ec2-user/gm/uploads/respatch_scorequest_android_a.zip
75 -> /home/ec2-user/gm/uploads/cpatch_scorequest_android_b.zip
76 -> /home/ec2-user/gm/uploads/respatch_scorequest_android_a.zip
77 -> /home/ec2-user/gm/uploads/bpatch_scorequest_android_a.zip
78 -> /home/ec2-user/gm/uploads/bpatch_scorequest_android_a.zip
79 -> /home/ec2-user/gm/uploads/respatch_scorequest_android_a.zip
Node.js:8.11.1
操作系统:Amazon Linux