express-zip-stream

1.0.1 • Public • Published

express-zip-stream

express-zip-stream allows you to serve zip files with express, without creating any intermediary files on disk.

const app = require('express')();
const zip = require('express-zip-serve');
 
app.get('/', function(req, res) {
  res.zip([
    { path: '/path/to/file1.name', name: '/path/in/zip/file1.name' }
    { path: '/path/to/file2.name', name: 'file2.name' }
  ]);
});
 
app.listen(3131);

API

/**
 * Responds with a ZIP attachment containing `files`, with an optional
 * "save as" `filename` (default is attachment.zip), and then calls `cb`
 * when finished.
 *
 * @param {Array} files { name: <name>, path: <path> }
 * @param {String|Function} filename that will be shown in "save as" dialog, UTF-8
 * @param {Function} cb(err, bytesZipped) optional
 */
res.zip = function(files, filename, cb) {

Credits

express-csv zip-stream

Readme

Keywords

Package Sidebar

Install

npm i express-zip-stream

Weekly Downloads

18

Version

1.0.1

License

none

Unpacked Size

4.61 kB

Total Files

5

Last publish

Collaborators

  • yalanyali