# @zhike/koa2-upload

> A middleware for koa2 to handle file upload based on formidable

Latest version **1.0.9** (published 2019-05-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install @zhike/koa2-upload
pnpm add @zhike/koa2-upload
yarn add @zhike/koa2-upload
bun add @zhike/koa2-upload
```

## 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.9 |
| Published | 2019-05-31 |
| First published | 2018-05-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | booksaye |
| Maintainers | banyudu, jayi, jiawei123, jiayufeng, maintao, renxing, shanyaxuan2015, smartfe, vipzhicheng, wansong, zhiker, zxdvd |
| Keywords | koa, koa2, middleware, file, upload |

## Links

- npm: https://www.npmjs.com/package/@zhike/koa2-upload
- Repository: https://github.com/zhike-team/koa2-upload
- Homepage: https://github.com/zhike-team/koa2-upload#readme
- Issues: https://github.com/zhike-team/koa2-upload/issues
- npm.io page: https://npm.io/package/@zhike/koa2-upload

## Dependencies (1)

- [formidable](https://npm.io/package/formidable.md) ^1.2.1

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 1.0.9 (latest) — 2019-05-31
- 1.0.7 — 2018-07-18
- 1.0.6 — 2018-07-18
- 1.0.5 — 2018-07-18
- 1.0.4 — 2018-06-14
- 1.0.3 — 2018-06-14
- 1.0.2 — 2018-06-14
- 1.0.0 — 2018-05-25

## README

# koa2-upload

基于formidable的，适用于koa2的处理文件上传的中间件

## 安装

```sh
npm i --save @zhike/koa2-upload
```

## 使用方法

```javascript
  const koa = require('koa');
  const app = new Koa();

  const fileHandler = require('koa2-upload');

  app.use(fileHandler({ autoDelete: true }))

  app.use(async (ctx)=>{

    // ctx.fields
    // ctx.files

  })
```

### Options

* stream: 默认值 false ， 设置为true会将上传文件流挂载在ctx.files[key].stream中
  
* autoDelete: 默认值 false ，设置为true在请求结束之后会删除本地缓存文件

* uploadDir: 设置为文件保存路径

* maxFileSize: 设置上传文件最大字节数

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