# @web3-storage/multipart-parser

> A simple multipart/form-data parser to use with ReadableStreams

Latest version **1.0.0** (published 2021-07-26) · (Apache-2.0 AND MIT) license · 0 weekly downloads

## Install

```sh
npm install @web3-storage/multipart-parser
pnpm add @web3-storage/multipart-parser
yarn add @web3-storage/multipart-parser
bun add @web3-storage/multipart-parser
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2021-07-26 |
| First published | 2021-07-26 |
| Weekly downloads | 0 |
| License | (Apache-2.0 AND MIT) |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 52.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | vasco-santos |
| Maintainers | olizilla, hugomrdias, vascosantos, alanshaw, ipfsbot |

## Links

- npm: https://www.npmjs.com/package/@web3-storage/multipart-parser
- Repository: https://github.com/web3-storage/multipart-parser
- Homepage: https://github.com/web3-storage/multipart-parser#readme
- Issues: https://github.com/web3-storage/multipart-parser/issues
- npm.io page: https://npm.io/package/@web3-storage/multipart-parser

## Recent versions

- 1.0.0 (latest) — 2021-07-26

## README

# multipart-parser

> A simple multipart/form-data parser to use with ReadableStreams

Based on https://github.com/ssttevee/js-multipart-parser

## Install

```sh
# install it as a dependency
$ npm i @web3-storage/multipart-parser
```

# Usage

```js
import { parseMultipart } from '@web3-storage/multipart-parser';

...

async function requestHandler(req) {
    const boundary = '----whatever';
    const parts = await parseMultipart(req.body, boundary);
    const fd = new FormData();
    for (const { name, data, filename, contentType } of parts) {
        if (filename) {
            fd.append(name, new Blob([data], { type: contentType }), filename);
        } else {
            fd.append(name, new TextDecoder().decode(data), filename);
        }
    }
}
```

## Releasing

You can publish by either running npm publish in the dist directory or using npx ipjs publish.

---
_Source: https://npm.io/package/@web3-storage/multipart-parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
