Package Exports
- dacong-koa-chunked-upload
- dacong-koa-chunked-upload/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (dacong-koa-chunked-upload) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
安装
npm install dacong-koa-chunked-upload@latest使用
const { chunkedUpload, fileGet, FileSchema } = require('dacong-koa-chunked-upload')
// chunkedUpload,fileGet依赖FileModel
/* 🌰 /router.js
const router = require('koa-router')()
const { FileModel } = require('@/config/mongodb')
const { chunkedUpload,fileGet } = require('dacong-koa-chunked-upload')
const SERVER_HOST = 'http://127.0.0.1:3001' //这个地址是你Koa服务的地址
router.use('/upload', chunkedUpload({FileModel,SERVER_HOST}))
router.use('/static', fileGet({FileModel}))
module.exports = router
*/
// FileModel 由 FileSchema 创建而来
/*🌰 /config/mongodb.js
const mongoose = require('mongoose')
const { FileSchema } = require('dacong-koa-chunked-upload')
mongoose.connect('mongodb://127.0.0.1:27017/miao-cut')
const FileModel = mongoose.model('File', FileSchema({
expired: false, //是否设置自动过期,默认false
days:1 //自动过期时间,默认为1天
}))
module.exports = { FileModel }
*/ 注意事项
- 这是
Koa的插件 - 依赖
mongodb数据库,采用的mongoose库 - 自动过期功能采用
FileSchema.index({ expired_time: 1 }, { expireAfterSeconds: 0 })方案,配置expired自动启用 - 这个包主要是完成
dacong-chunked-upload包的服务端部分