如何在Node.js中创建弹出式下载链接?

时间:2019-06-23 21:32:01

标签: node.js download fs youtube-dl content-disposition

我想创建一个弹出下载链接,目前正在直接在我的计算机上下载它,但是我想创建一个弹出链接,以便当我单击“确定”时它将开始下载。

var video = youtubedl('https://www.youtube.com/watch?v=dPI-mRFEIH0',
  // Optional arguments passed to youtube-dl.
  ['--format=18'],
  // Additional options can be given for calling `child_process.execFile()`.
  { cwd: __dirname });

// Will be called when the download starts.
video.on('info', function(info) {
  console.log('Download started');
  console.log('filename: ' + info._filename);
    console.log('size: ' + info.size);
    video.pipe(fs.createWriteStream(info._filename));

0 个答案:

没有答案