Skip to content

Instantly share code, notes, and snippets.

@Galaxy83
Last active February 16, 2023 18:29
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Galaxy83/c1fdeec84d0c0c51ab78057a72385a7b to your computer and use it in GitHub Desktop.
Save Galaxy83/c1fdeec84d0c0c51ab78057a72385a7b to your computer and use it in GitHub Desktop.
node.js zlib decompress uncompress unzip s3 file getObject buffer
const unzipFromS3 = (key, bucket) => {
return new Promise(async (resolve, reject) => {
let options = {
'Bucket': bucket,
'Key': key,
};
s3.getObject(options, function(err, res) {
if(err) return reject(err);
resolve(zlib.unzipSync(res.Body).toString());
});
});
};
@stkrzysiak
Copy link

thank you for posting this!

@farheen87
Copy link

Error: incorrect header check
at Zlib.zlibOnError when executing this
any solution

@Galaxy83
Copy link
Author

Galaxy83 commented Jan 6, 2021

Error: incorrect header check
at Zlib.zlibOnError when executing this
any solution

Not out of my head. Make sure the s3 object is a valid gziped file. FYI, res.Body is a buffer.

@mradul070
Copy link

Error: incorrect header check
at Zlib.zlibOnError when executing this
any solution

Not out of my head. Make sure the s3 object is a valid gziped file. FYI, res.Body is a buffer.

I am getting the same error, I also got a content type binary/octet but's still not unzipped my keys it will give error header check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment