# @qingh/upload

> ``` import { parse } from 'url'; import { createServer } from 'http'; import upload from '@qingh/upload'; const port = 8080;

Latest version **1.0.2** (published 2020-07-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install @qingh/upload
pnpm add @qingh/upload
yarn add @qingh/upload
bun add @qingh/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.2 |
| Published | 2020-07-12 |
| First published | 2020-07-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4.7 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | qingh |
| Maintainers | qingh |
| Keywords | upload |

## Links

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

## Dependencies (1)

- [uuid](https://npm.io/package/uuid.md) ^8.2.0

## Recent versions

- 1.0.2 (latest) — 2020-07-12
- 1.0.1 — 2020-07-12
- 1.0.0 — 2020-07-12

## README

## 原生 nodejs 实现上传

#### 使用说明

```
import { parse } from 'url';
import { createServer } from 'http';
import upload from '@qingh/upload';
const port = 8080;

createServer(async (req, res) => {
	const { pathname } = parse(req.url, true);
 	if (pathname === '/api/v1/upload') {
    if (req.method.toLowerCase() === 'post') {
    	res.setHeader('content-type', 'application/json;charset=utf8');
      try {
        let data = await upload(req, res, {
          uploadDir: 'upload',
          type: ['jpg', 'png','gif'],
          maxSize: 5 * 1024 * 1024
        });
				res.write('upload success');
      } catch (error) {
        res.write('upload fail');
      }
			res.end();
    }
  }else{
		//other codes
	}
}).listen(port);

```

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