Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dzy321/file-upload
koa2 middleware support upload to cos/oss/obs/aws/local
https://github.com/dzy321/file-upload
cos koa2 obs oss upload
Last synced: 19 days ago
JSON representation
koa2 middleware support upload to cos/oss/obs/aws/local
- Host: GitHub
- URL: https://github.com/dzy321/file-upload
- Owner: dzy321
- Created: 2016-10-14T02:25:58.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-06T22:49:57.000Z (almost 2 years ago)
- Last Synced: 2024-10-12T05:06:51.156Z (about 1 month ago)
- Topics: cos, koa2, obs, oss, upload
- Language: JavaScript
- Homepage:
- Size: 298 KB
- Stars: 29
- Watchers: 5
- Forks: 8
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# koa2-file-upload
[![](https://img.shields.io/npm/v/koa2-file-upload.svg?style=flat)](https://www.npmjs.com/package/koa2-file-upload)
koa2 middle to upload file, 支持文件系统、 阿里 oss 、腾讯 cos 、华为 obs 、azure
### Features
- support upload to dir
```javascript
options['upload'] = {
"url": '/api/upload',
"storeDir": 'xxx',
"provider": "local",
"mimetypes": ['image/png','image/bmp'], // 如果没有配置,将不进行类型检查 http://www.freeformatter.com/mime-types-list.html
"folder": "public",
"urlPath": "images",
}
```- support upload to oss
```javascript
options["upload"] = {
"url": '/api/upload',
"provider": "oss",
"storeDir": 'xxx',
"mimetypes": ['image/png','image/bmp'],
"accessKeyId": "key",
"accessKeySecret": "secret",
"bucket": "terminus-designer",
"region": "oss-cn-hangzhou",
"filename": (file) => `${new Date().getTime()}-${file.filename}`, // default null
"targetProtocol": "http", // default null
"attachment": true // default null
}
```- support upload to cos
```javascript
options["upload"] = {
"url": '/api/upload',
"provider": "cos",
"storeDir": 'xxx',
"bucket": "b2b",
"appId": "xxx",
"secretID": "xxx",
"secretKey": "xx",
"region": "gz"
}
```- support upload to obs
```javascript
options["upload"] = {
"url": '/api/upload',
"provider": "obs",
"bucket": "****",
"accessKeyId": "****",
"accessKeySecret": "****",
"server": "****"
}
```- support upload to azure
```javascript
options["upload"] = {
"url": '/api/upload',
"provider": "azure",
"container": "xxxx",
"account": "xxxx",
"connectionString": "xxxx",
}
```- support upload to aws
```javascript
options["upload"] = {
"url": '/api/upload',
"endpoint": "http://localhost:801",
"provider": "aws",
"bucket": "****",
"accessKeyId": "****",
"secretAccessKey": "****",
"s3ForcePathStyle": true, // minio support
"signatureVersion": "v4" // minio support
}
```### How to use
```javascript
npm i koa2-file-upload
app.use(uploader(options))
```### Requirements
- Node v6.0+
## Workflow
- `npm install`