求大神指点下迷津,感谢
var fileReadStream = fs.createReadStream(‘http://i.lefull.cn/css_twice/public/useFont.css’); var fileWriteStream = fs.createWriteStream(‘app.css’); fileReadStream.pipe(fileWriteStream);
fileWriteStream.on(‘close’,function(){ console.log(‘copy over’); }); 怎么远程的文件写不进本地么?是我代码有问题 还是不允许这样操作呢
3 回复
不允许远程文件这样读写,远程你可以用request操作,读取文件只能是本地路径的
来自酷炫的 CNodeMD
哦哦 好的 我试试 感谢
import request from "superagent";
import fs from "fs";
request.get("https://dn-cnode.qbox.me/Fk9ptLpB2uwdPZAUYml60pEZwVU6")
.end((err,rep)=>{
let file = fs.createWriteStream("a.jpg");
rep.pipe(file);
})