Skip to content

stevevista/koa-partial-upload

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Notices

require Node version > 8.0.0

Code

Server

const PartialUpload = require('koa-partial-upload')
const Router = require('koa-router')

const router = Router()

router.post('/upload', PartialUpload({
  uploadDir: './tmp',
  maxFileSize: 200 * 1024 * 1024
}), async ctx => {
  if (!ctx.request.files) {
    // not multipart upload
  } else if (ctx.request.files.file.partial) {
    // a partial file segment
    // console.log(ctx.request.body.trunks)
    // console.log(ctx.request.body.eot)
  } else {
    // a single uplaod or merged upload
    // file.size is the merged size
  }
})


Client

curl -F "file=@card.txt" -F "imei=222222222" -F "hash=my_key" -F "trunks=1" http://localhost:3001/log/upload
curl -F "file=@card.txt" -F "imei=222222222" -F "hash=my_key" -F "trunks=2" -F "eot=1" http://localhost:3001/log/upload

if hash is not presented, then original filename will be used as identity

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published