Skip to content

dzy321/file-upload

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

koa2-file-upload

koa2 middle to upload file, 支持文件系统、 阿里 oss 、腾讯 cos 、华为 obs 、azure

Features

  • support upload to dir
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
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
options["upload"] = {
  "url": '/api/upload',
  "provider": "cos",
  "storeDir": 'xxx',
  "bucket": "b2b",
  "appId": "xxx",
  "secretID": "xxx",
  "secretKey": "xx",
  "region": "gz"
}
  • support upload to obs
options["upload"] = {
  "url": '/api/upload',
  "provider": "obs",
  "bucket": "****",
  "accessKeyId": "****",
  "accessKeySecret": "****",
  "server": "****"
}
  • support upload to azure
options["upload"] = {
  "url": '/api/upload',
  "provider": "azure", 
  "container": "xxxx",
  "account": "xxxx",
  "connectionString": "xxxx",
}
  • support upload to aws
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

npm i koa2-file-upload

app.use(uploader(options))

Requirements

  • Node v6.0+

Workflow

  • npm install

About

koa2 middleware support upload to cos/oss/obs/aws/local

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published