Skip to content

Instantly share code, notes, and snippets.

@willwillems
Created August 12, 2019 19:07
Show Gist options
  • Save willwillems/41acdf7ef70dba9157b0f59eae565b54 to your computer and use it in GitHub Desktop.
Save willwillems/41acdf7ef70dba9157b0f59eae565b54 to your computer and use it in GitHub Desktop.
Get .zip file with Node, unzip it and save it to disk by piping the response body into unzipper
const unzipper = require('unzipper');
const fetch = require('node-fetch')
// get data
fetch('https://example.org/my-archive.zip')
.then(resp => {
return new Promise((res, rej) => {
resp.body
.pipe(unzipper.Extract({ path: '/tmp/my-archive' }))
.on('error', rej)
.on('finish', res);
})
})
.catch(console.error)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment