[英]Error: absolute path: //fileName/ unzipping a folder in protractor nodejs
I tried many ways available in different sites to unzip the downloaded zipped folder and found the below one is simplest way.However, am facing the below issue.Please help me resolve this:我尝试了不同站点中可用的多种方法来解压缩下载的压缩文件夹,发现以下一种是最简单的方法。但是,我面临以下问题。请帮我解决这个问题:
const extract = require('extract-zip');
const path = require('path');
unzip=async function(){
let source = "Downloads/sample.zip";
let destination = "Downloads/";
let sP = path.resolve(source);
console.log("Source path : " +sP);
let dP = path.resolve(destination);
console.log("Destination path : " +dP);
await extract(sP, { dir: dP });
console.log('Extraction complete');
}
Output: Output:
Source path : /Users/myName/Documents/framework/Downloads/sample.zip
Destination path :/Users/myName/Documents/framework/Downloads
.
.
Error: absolute path://sample/
The resolved path should be relative to the path of the directory where the code is being executed.解析的路径应该是相对于正在执行代码的目录的路径。
Replace代替
let source = '../../Downloads/sample.zip
let destination = '../../Downloads
let sP = path.resolve(source);
let dP = path.resolve(destination);
The problem is the.zip file itself starting with //.问题是 .zip 文件本身以 // 开头。 Extract-zip uses yauzl which throws an exception if it's an absolute path: https://github.com/thejoshwolfe/yauzl/issues/135
Extract-zip 使用 yauzl,如果它是绝对路径,则会引发异常: https://github.com/thejoshwolfe/yauzl/issues/135
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.