# @trubavuong/fastify-multipart

> A wrapper of fastify-multipart with confident mimetype

Latest version **1.0.0** (published 2021-05-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install @trubavuong/fastify-multipart
pnpm add @trubavuong/fastify-multipart
yarn add @trubavuong/fastify-multipart
bun add @trubavuong/fastify-multipart
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2021-05-29 |
| First published | 2021-05-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 7.2 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Vuong Tru |
| Maintainers | trubavuong |
| Keywords | node, nodejs, fastify, multipart |

## Links

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

## Dependencies (3)

- [file-type](https://npm.io/package/file-type.md) ^16.4.0
- [fastify-plugin](https://npm.io/package/fastify-plugin.md) ^3.0.0
- [fastify-multipart](https://npm.io/package/fastify-multipart.md) ^4.0.6

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2021-05-29

## README

# fastify-multipart

A wrapper of [fastify-multipart](https://github.com/fastify/fastify-multipart) with [confident mimetype](https://github.com/sindresorhus/file-type)
which [accumulates whole file in memory](https://github.com/fastify/fastify-multipart#parse-all-fields-and-assign-them-to-the-body).

## Note

This plugin has some characteristics:

1. Loads whole file in memory, so don't use this plugin if you want to upload large files!
2. Assign all fields to the body, so you can use JSON schema to validate them
3. MIME type only works with binaries, such as images, videos, documents...

## Install

```
$ npm install @trubavuong/fastify-multipart
```

## Usage

```
const fastify = require('fastify');
const plugin = require('@trubavuong/fastify-multipart');

const app = fastify();
app.register(plugin);
```

## JSON schema

You should write your own JSON schema to fit your need. Here is an example of the `req.body`:

```
{
  name: {
    fieldname: 'name',
    value: 'Vuong Tru',
  },
  avatar: {
    fieldname: 'avatar',
    filename: 'image.jpg',
    encoding: '7bit',
    mimetype: 'image/jpeg', // original mimetype
    mime: 'image/jpeg',     // corrected mimetype, added by this plugin
    ext: 'jpg',             // corrected extension, added by this plugin
    toBuffer: <function>
  }
}
```

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