📜  node js请求下载文件 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:04:28.689000             🧑  作者: Mango

代码示例1
const http = require('http'); // or 'https' for https:// URLs
const fs = require('fs');

const file = fs.createWriteStream("file.jpg");
const request = http.get("http://i3.ytimg.com/vi/J---aiyznGQ/mqdefault.jpg", function(response) {
  response.pipe(file);
});