var request = require(‘request’);
const fs = require(“fs”);
request(‘http://172.16.12.231:8081/chat/api/io/get/pic/img_1482227077533323266.zip’).pipe(fs.createWriteStream(‘doodle.png’))
return false;
const downloadFile = (async (url, path) => {
const res = await fetch(url);
const fileStream = fs.createWriteStream(path);
debugger;
await new Promise((resolve, reject) => {
res.body.pipe(fileStream);
res.body.on(“error”, reject);
fileStream.on(“finish”, resolve);
debugger;
});
let str=downloadFile(fileUrl,AppPath);
var dirPath = path.join(__dirname, “file”);
if (!fs.existsSync(dirPath)) {
fs.mkdirSync(dirPath);
console.log(“文件夹创建成功”);
} else {
console.log(“文件夹已存在”);
}