Skip to content

WebNinjaDeveloper.com

Programming Tutorials




Menu
  • Home
  • Youtube Channel
  • Official Blog
  • Nearby Places Finder
  • Direction Route Finder
  • Distance & Time Calculator
Menu

Node.js Express Tutorial to Download Multiple Files at Once Using express-zip Library in Javascript

Posted on January 19, 2023

 

 

Welcome folks today in this blog post we will be downloading multiple files at once using express-zip library in browser using node.js and express in javascript. All the full source code of the application is shown below.

 

 

Get Started

 

 

In order to get started you need to initialize a new node.js project using the below command

 

 

npm init -y

 

 

npm i express

 

 

npm i express-zip

 

 

Now we need to make the index.js file and copy paste the following code

 

 

index.js

 

 

1
2
3
4
5
6
7
8
9
10
11
var app = require('express')();
let zip = require('express-zip')
 
app.get('/', function(req, res) {
  res.zip([
    { path: 'file1.pdf', name: 'file1.pdf' },
    { path: 'file2.pdf', name: 'file2.pdf' }
  ]);
});
 
app.listen(3000);

 

 

As you can see we are importing the express and express-zip libraries at the top and then we are making the get route at the / homepage and inside it we are using the zip() method inside which we are passing the array of files in which we have two properties in which we are passing the path of the file and then we are passing the filename of the file to be compressed and then we are starting the node.js and express at port 3000.

 

 

 

 

Recent Posts

  • Android Java Project to Merge Multiple PDF Documents From Gallery Using iTextPDF Library
  • Android Java Project to Detect System Hardware & System CPU Info & Display inside TextView Widget
  • Android Java Project to Integrate Google OAuth2 Login & Logout System & Save User Info in SharedPreferences
  • Android Java Project to Export Raw Text to PDF Document Using iTextPDF Library
  • Android Java Project to Export Images From Gallery to PDF Document Using iTextPDF Library
  • Angular
  • Bunjs
  • C#
  • Deno
  • django
  • Electronjs
  • java
  • javascript
  • Koajs
  • kotlin
  • Laravel
  • meteorjs
  • Nestjs
  • Nextjs
  • Nodejs
  • PHP
  • Python
  • React
  • ReactNative
  • Svelte
  • Tutorials
  • Vuejs




©2023 WebNinjaDeveloper.com | Design: Newspaperly WordPress Theme