嘿,我是nodejs的新手,我用它做了一个应用程序管理器。
在应用程序管理器中,我想从以下直接链接下载文件:
https://download.oracle.com/otn-pub/java/jdk/15.0.1%2B9/51f4f36ad4ef43e39d0dfdbaf6549e32/jdk-15.0.1_windows-x64_bin.zip
如果我单击该链接,我将下载这些文件,但我想在NodeJS中这样做。
有人能告诉我怎么做吗?
谢谢你帮我。
发布于 2020-12-12 05:57:04
const http = require('http');
const fs = require('fs');
const url = “...” // whatever url you want
const filePath = “...” // where ever you want save the file along with the file name you want and extension example (here/file.zip)
const file = fs.createWriteStream(filepath);
const request = http.get(url, (response) => {
response.pipe(file);
});试试这段代码
https://stackoverflow.com/questions/65261843
复制相似问题