Created
August 12, 2019 19:07
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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