请问 res.download 可以直接下载远程文件吗
app.get(’/download’,function(req, res, next){ res.download(“https://o4j806krb.qnssl.com/public/images/cnodejs_light.svg”); });
运行提示 找不到目录 Error: ENOENT: no such file or directory
2 回复
@chyingp 前辈提供的方向很好,我这边做了一个简易实例供楼主参考看看:
const request = require('request');
const http = require('http');
const url = 'https://o4j806krb.qnssl.com/public/images/cnodejs_light.svg';
const app = http.createServer((req, res) =>
request.get(url).pipe(res)
);
app.listen(3000);