# multer-zip

> Promise based multer file upload zipping utility

Latest version **1.2.0** (published 2022-12-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install multer-zip
pnpm add multer-zip
yarn add multer-zip
bun add multer-zip
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2022-12-06 |
| First published | 2020-01-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Dillon Streator |
| Maintainers | dillonstreator |
| Keywords | multer, zip, express, multer-zip, express-multer-zip |

## Links

- npm: https://www.npmjs.com/package/multer-zip
- Repository: https://github.com/DillonStreator/multer-zip
- Homepage: https://github.com/DillonStreator/multer-zip#readme
- Issues: https://github.com/DillonStreator/multer-zip/issues
- npm.io page: https://npm.io/package/multer-zip

## Dependencies (1)

- [archiver](https://npm.io/package/archiver.md) 5.3.1

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 1.2.0 (latest) — 2022-12-06
- 1.1.0 — 2020-01-25
- 1.0.1 — 2020-01-25
- 1.0.0 — 2020-01-25

## README

# multer-zip

> Promise based multer file upload zipping utility

# Example

```javascript
const path = require("path");

const express = require("express");
const zipper = require("multer-zip").default;
const multer = require("multer");
const upload = multer(/* ... multer opts ... */);
const app = express();

// ... app definitions

app.post("/", upload.array("documents", 5), (req, res) => {
	const { files } = req;
	const dest = path.join(__dirname, "uploads");
	const zipname = `files_${Math.random()}.zip`;
	const filenamer = ({ originalname }) => `${new Date().getTime()}_${originalname}`;
	zipper({ files, dest, zipname, filenamer })
		.then(() => {
			console.log("successfully zipped files");
		})
		.catch(error => {
			console.log(error);
		});

	res.send("zipping...");
});

app.post("/streamable", upload.array("documents", 5), (req, res) => {
	const { files } = req;
	const filenamer = ({ originalname }) => `${new Date().getTime()}_${originalname}`;
	zipper({ files, dest: res, filenamer })
		.then(() => {
			console.log("successfully zipped files");
		})
		.catch(error => {
			console.log(error);
		});
});

const PORT = process.env.PORT || 3000;
app.listen(PORT => console.log(`listening on port ${PORT}`));
```

# Options

Key | Description | Note
--- | --- | ---
`files` | Multer files array | **\*Must contain buffers**
`dest` | Destination of zipped files or `stream.Writable` |
`zipname` | Name of zipped files |
`filenamer` | Optional function to change name of file |

---
_Source: https://npm.io/package/multer-zip · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
