how to download a file with Nodejs(without using third-party libraries)用node下载文件
创建HTTP GET
请求并将其管理response
到可写文件流中:
var http = require('http'); var fs = require('fs'); var file = fs.createWriteStream("file.jpg"); var request = http.get("http://blog.mongolab.com/wp-content/uploads/2014/01/data_extents1-1024x430.png", function(response) { response.pipe(file); });