Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does this library works with .zipx file? #233

Open
amitshahi19589 opened this issue Feb 22, 2021 · 0 comments
Open

Does this library works with .zipx file? #233

amitshahi19589 opened this issue Feb 22, 2021 · 0 comments

Comments

@amitshahi19589
Copy link

amitshahi19589 commented Feb 22, 2021

I am trying to unzip .zipx file which is uploaded on S3 bucket but it is not working.

Error:
`events.js:292
throw er; // Unhandled 'error' event
^

Error: too many length or distance symbols
at Zlib.zlibOnError [as onerror] (zlib.js:182:17)
Emitted 'error' event on PassThrough instance at:
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
errno: -3,
code: 'Z_DATA_ERROR'
}`

Code :
`const unzipper = require('unzipper');
const fs = require('fs');
const AWS = require('aws-sdk');

const config = {
region: '',
secretAccessKey: '',
sessionToken: '',
accessKeyId: ''
};

const s3Client = new AWS.S3(config);

async function main() {
const directory = await unzipper.Open.s3(s3Client, {
Bucket: 'test-bucket',
Key: 'zipfiles/BPrint.zipx'
});
const files = directory.files;
const folderName = './unzippedfiles';
try {
if (!fs.existsSync(folderName)) {
fs.mkdirSync(folderName);
}
} catch (err) {
console.error(err);
}
console.log(files);
try {
for (const file of files) {
await file.stream().pipe(fs.createWriteStream(${folderName}/${file.path}));
}
} catch (e) {
console.log(e);
}
}

main();
`
Thanks,

@amitshahi19589 amitshahi19589 changed the title Does this library works with .zipx file. Does this library works with .zipx file? Feb 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant