gpt4 book ai didi

linux - 在nodejs中使用子进程创建密码保护的zip文件

转载 作者:太空宇宙 更新时间:2023-11-04 10:41:48 24 4
gpt4 key购买 nike

我有一个非常有趣的问题。我在 nodejs 中生成一个子进程来创建一个 zip 密码保护文件。它应该模拟以下命令。

zip -P password -rf finalFileName.zip filePath

这是我写的代码

function(password, zipName) {

let zip = spawn('zip', ['-P rolemodel','-rj', zipName, this.folderPath ]);

return this;

}

在解压缩最终的 zip 文件时,出现密码无效错误。

我在这里做错了什么?但是,我能够在终端上执行命令并使整个工作正常进行。

最佳答案

也许您可以尝试将每个参数都放在引号中,如下所示:

zip = spawn('zip',['-P', 'password' , '-rj', 'archive.zip', 'complete path to archive file']);
zip .on('exit', function(code) {
...// Do something with zipfile archive.zip
...// which will be in same location as file/folder given
});

关于linux - 在nodejs中使用子进程创建密码保护的zip文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34768898/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com