# sp-upload

> sp-upload,sp-base,upload

Latest version **1.1.3** (published 2017-03-03) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install sp-upload
pnpm add sp-upload
yarn add sp-upload
bun add sp-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.1.3 |
| Published | 2017-03-03 |
| First published | 2017-02-13 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | cs_victor@126.com |
| Maintainers | dongwenxiao |
| Keywords | sp-upload, sp-base, upload |

## Links

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

## Dependencies (5)

- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.1
- [moment](https://npm.io/package/moment.md) ^2.17.1
- [sp-model](https://npm.io/package/sp-model.md) ^1.0.0
- [koa-multer](https://npm.io/package/koa-multer.md) ^1.0.1
- [sp-response](https://npm.io/package/sp-response.md) ^1.0.0

## Recent versions

- 1.1.3 (latest) — 2017-03-03
- 1.1.2 — 2017-02-20
- 1.1.1 — 2017-02-20
- 1.1.0 — 2017-02-16
- 1.0.1 — 2017-02-13
- 1.0.0 — 2017-02-13

## README

# sp-upload
Upload file module for sp-base

## 逻辑

上传文件到指定文件夹，数据表记录上传的文件。

## 使用

```
import { spUpload } from 'sp-upload'

const uploadService = new spUpload(
    Object.assign({ip: '127.0.0.1', port: '23707', db: 'db_name'}, {
        prefix: '/upload',  // api path
        domain: 'http://localhost:3000/upload/',  // publish url
        collection: 'my_collection_name' // custom collection name
    }),
    serverRouter,
    serverMiddleware
)
uploadService.mount()
```

## 接口

```
// 请求

url: /upload/file
type: form-data
param: file,[folder]
```

```
// 返回值

{
  "code": 200,
  "data": {
    "url": "http://localhost:3000/upload/b868c07f01b976b0fe5fb31a8f915586.jpg",
    "originalFilename": "body.jpg",
    "filename": "b868c07f01b976b0fe5fb31a8f915586.jpg",
    "encoding": "7bit",
    "mimeType": "image/jpeg",
    "folder": "",
    "_id": "58aa850fcc537a39e6450477"
  },
  "msg": "上传成功"
}
```

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