digitaldrummerj.me - How to Download and Extract a Zip File with Node









Search Preview

Justin James

digitaldrummerj.me

.me > digitaldrummerj.me

SEO audit: Content analysis

Language Error! No language localisation is found.
Title Justin James
Text / HTML ratio 32 %
Frame Excellent! The website does not use iFrame solutions.
Flash Excellent! The website does not have any flash contents.
Keywords cloud zip file = directory const Node extract find code AdmZip Zip Extract change superagent downloaded File save fs package download
Keywords consistency
Keyword Content Title Description Headings
zip 19
file 17
= 10
directory 9
const 9
Node 6
Headings
H1 H2 H3 H4 H5 H6
2 3 5 0 2 0
Images We found 1 images on this web page.

SEO Keywords (Single)

Keyword Occurrence Density
zip 19 0.95 %
file 17 0.85 %
= 10 0.50 %
directory 9 0.45 %
const 9 0.45 %
Node 6 0.30 %
extract 5 0.25 %
find 5 0.25 %
code 5 0.25 %
AdmZip 5 0.25 %
Zip 4 0.20 %
Extract 4 0.20 %
change 4 0.20 %
superagent 4 0.20 %
downloaded 4 0.20 %
File 4 0.20 %
save 3 0.15 %
fs 3 0.15 %
package 3 0.15 %
download 3 0.15 %

SEO Keywords (Two Word)

Keyword Occurrence Density
zip file 15 0.75 %
the zip 9 0.45 %
to a 5 0.25 %
a directory 5 0.25 %
change to 4 0.20 %
code below 4 0.20 %
Zip File 4 0.20 %
to extract 4 0.20 %
Justin James 3 0.15 %
TODO change 3 0.15 %
Extract a 3 0.15 %
to the 3 0.15 %
of the 3 0.15 %
all of 3 0.15 %
find a 3 0.15 %
file and 3 0.15 %
the code 3 0.15 %
the requirements 2 0.10 %
but I 2 0.10 %
I did 2 0.10 %

SEO Keywords (Three Word)

Keyword Occurrence Density Possible Spam
the zip file 6 0.30 % No
zip file and 3 0.15 % No
TODO change to 3 0.15 % No
to a directory 3 0.15 % No
the code below 3 0.15 % No
and Extract a 2 0.10 % No
a Zip File 2 0.10 % No
Zip File with 2 0.10 % No
File with Node 2 0.10 % No
change to the 2 0.10 % No
to the directory 2 0.10 % No
code below to 2 0.10 % No
within the zip 2 0.10 % No
to Download and 2 0.10 % No
the Zip File 2 0.10 % No
a zip file 2 0.10 % No
I didn’t find 2 0.10 % No
you want to 2 0.10 % No
want to extract 2 0.10 % No
zip file is 2 0.10 % No

SEO Keywords (Four Word)

Keyword Occurrence Density Possible Spam
Download and Extract a 2 0.10 % No
you want to extract 2 0.10 % No
Extract a Zip File 2 0.10 % No
and Extract a Zip 2 0.10 % No
to Download and Extract 2 0.10 % No
How to Download and 2 0.10 % No
change to the directory 2 0.10 % No
TODO change to the 2 0.10 % No
within the zip file 2 0.10 % No
Zip File with Node 2 0.10 % No
a Zip File with 2 0.10 % No
but I did find 2 0.10 % No
zipextractEntryToextractEntryTo outputDir false true 1 0.05 % No
consolelog'finished unzip' Just like 1 0.05 % No
true consolelog'finished unzip' Just 1 0.05 % No
a directory consolelog'finished downloading' 1 0.05 % No
false true consolelog'finished unzip' 1 0.05 % No
outputDir false true consolelog'finished 1 0.05 % No
directory consolelog'finished downloading' var 1 0.05 % No
unzip' zipextractEntryToextractEntryTo outputDir false 1 0.05 % No

Digitaldrummerj.me Spined HTML


Justin James Justin James Navigation Home Speaking Engagements Blog Workshops Workshops Rapid API Development with SailsJS Up and Running with Angular About Contact Search How to Download andPericopea Zip File with Node Wed Feb 07, 2018 node Downloading and extracting a zip file using Node seemed like a pretty easy task but alas it took some time to icon out. While researching how to do this, I didn’t find a library that had all of the requirements within it but I did find a few that unliable me to meet the requirements Requirements Download zip file from a urlPericopezip file to a directory locationPericopea single directory and all of its sub-directories within the zip file Downloading the Zip File Step 1 was to get the zip file downloaded using Node and make sure that I could manually unshut it. To download the zip file, I am using the superagent package and piping the download to a file using fs. Install superagent package npm install --save superagent Using superagent withal with fs we can download a zip file and save the zip to a local file. In the lawmaking below, I am downloading the zip for the master workshop of the Github repo located at https://github.com/digitaldrummerj/node-zip-download-sample. There are “TODO” statements in the lawmaking unelevated for the things that you would need to transpiration to use this lawmaking for your own zip file. 'use strict'; // Import const request = require('superagent'); const fs = require('fs'); // TODO: transpiration to where your zip file is located const repoName = 'node-zip-download-sample'; const href = `https://github.com/digitaldrummerj/${repoName}/archive`; const zipFile = 'master.zip'; const source = `${href}/${zipFile}`; // TODO: transpiration to the directory instead of the zip that you want to pericope const extractEntryTo = `${repoName}-master/`; // TODO: transpiration to the directory where you want to pericope to const outputDir = `./${repoName}-master/`; request .get(source) .on('error', function(error) { console.log(error); }) .pipe(fs.createWriteStream(zipFile)) .on('finish', function() { // add lawmaking unelevated to here }); Now that the zip file is downloaded we can unzip it. Unzipping the Zip File For unzipping, I didn’t find anything built into Node but I did find the Adm-Zip package on NPM. Adm-Zip has functions for dealing with the unshortened zip file or a single file/directory within the zip file. In my specimen all of my files were contained within a directory in the zip file and I wanted to pericope the files contained within that directory. Install Adm-Zip npm install --save adm-zip Add Adm-Zip to the list of requires const admZip = require('adm-zip'); Within the on finish statement from the previous section, add the lawmaking unelevated to use Adm-Zip to pericope a directory from the downloaded zip file and pericope it to a directory console.log('finished downloading'); var zip = new admZip(zipFile); console.log('start unzip'); zip.extractEntryTo(extractEntryTo, outputDir, false, true); console.log('finished unzip'); Just like that we had our zip file downloaded and extracted to a directory. You can find a working sample at https://github.com/digitaldrummerj/node-zip-download-sample Leave a scuttlebutt unelevated if you end up using this solution or are doing it flipside way. Share Post: Subscribe RSS Feed Atom Feed Recent Posts (All Posts) How to Download andPericopea Zip File with Node How I Record My Conference Talks AngularJS - Why is there an ! in my url now? Automatically Tweet New Blog Post Angular - No Test Found Archive By Date By Category By Tag Cloud Categories Android  (1) Angular  (4) Angularjs  (5) Bash  (1) Blogging  (18) Book Reviews  (1) Bower  (2) C Sharp  (1) Camtasia  (2) Chocolatey  (5) Chrome  (2) Debugging  (2) Docker  (3) Git  (5) Github  (5) Gulp  (4) How To  (1) Iis  (1) Ionic  (16) Jekyll  (16) Markdown  (1) Node  (1) Nodejs  (3) Npm  (4) Nuget  (1) Powershell  (1) Productivity  (5) Programming  (1) Proxy  (2) Recording  (1) Speaking  (4) Strongloop  (1) Vagrant  (9) Virtualbox  (6) Visual Studio  (6) Web Api  (3) Windows  (4) Year in Review  (1) About This Site Sharing my knowledge with others in a manner that is easy to understand and consume. More › Services Contact RSS Atom Created with ♥ by Justin James. All content is the property of Justin James and digitaldrummerj.me. This blog, its content, and opinions are my own.