Wednesday 26 April 2017

tar file extraction nodejs npm

I am trying to extract a tar file, that I will receive from the web-browser client onto a SUSE server. I have installed tar.gz npm for doing my stuff. But it always throws the same error. Below is the function.

function extract(){
    var name = "C:\\MyDrive\\parsing\\1.zip";
    targz().extract(name, 'C:\\MyDrive', function(err){
    if(err)
        console.log('Something is wrong ', err.stack);
    console.log('Job done!');
    });
}

Below is the error.

\root\server>node test.js
Something is wrong  Error: incorrect header check
    at Zlib._handle.onerror (zlib.js:370:17)
Job done!

Well this error is coming even in Windows also. When I create a tar file in windows and extract the same tar file in windows with the same function above. I believe either I am not using the npm currectly.

Is their any other npm and a working sample code for the same, which can extract the tar file uploaded by client. Extraction need to be achieved through some nodejs npm in javascript.



via Hemant Yadav

No comments:

Post a Comment