[英]How would I unzip a zip file in node
我想在沒有任何外部庫的情況下在節點中解壓縮 a.zip 文件。 我將如何 go 這樣做?
我試過使用 zlib 但它返回不正確的 header 類型
let zipfile = fs.readFileSync(fileinfomation.savelocation)
zlib.gunzipSync(zipfile)
編輯我也試過使用
let zipfile = fs.readFileSync(fileinfomation.savelocation)
zlib.unzipSync(zipfile)
它返回我導致了以下錯誤 Uncaught Error Error: incorrect header check
鏈接到 zip https://code.visualstudio.com/sha/download?build=stable&os=win32-x64-archive
zlib 似乎不支持解壓縮整個 zip 文件存檔(包含多個文件),這就是您的 visual studio zip 文件。
您將不得不使用支持解壓縮 zip 存檔文件的不同庫(NPM 上有許多支持該文件的庫),或者您可以使用 child_process 運行系統上已有的 zip 解壓縮程序。
如果這是 windows,您可以運行(使用 child_process)內置的tar.exe
來解壓縮 zip 歸檔文件,或者您可以獲得自己的命令行解壓縮程序(我自己使用 7-zip)並將其作為 child_process 運行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.