有没有一种方法可以从缓冲区执行文件而不提供文件路径?

时间:2019-10-29 09:48:31

标签: node.js stream buffer executable

以标准方式,我们将使用以下命令从存储中执行nodejs中的文件:  https://nodejs.org/api/child_process.html#child_process_child_process_execfilesync_file_args_options

我想知道是否有可能直接从内存中执行文件而不必先将其保存到磁盘上?

该用法是在您发出http请求,获取文件缓冲区,而不是通过管道保存(而不是通过管道)的情况下执行的(通过或不通过管道)。

// the way it would be in case you save the file
fetch('https://assets-cdn.github.com/images/modules/logos_page/Octocat.png')
    .then(res => {
        const dest = fs.createWriteStream('./octocat.png');
        res.body.pipe(dest);
    });

0 个答案:

没有答案
相关问题