JSPM

dacong-koa-chunked-upload

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q29348F
  • License ISC

拥有时间信息的 consola

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 }
*/ 

注意事项

  1. 这是 Koa 的插件
  2. 依赖 mongodb 数据库,采用的 mongoose
  3. 自动过期功能采用 FileSchema.index({ expired_time: 1 }, { expireAfterSeconds: 0 }) 方案,配置 expired 自动启用
  4. 这个包主要是完成 dacong-chunked-upload 包的服务端部分