0.3.0 • Published 2 years ago

@octoris/multipart v0.3.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Multipart

A multipart middleware for octoris

Install

You can install this middleware via npm

npm i @octoris/multipart

Options

There are some options multipart accepts

  • mimeTypes: Array - An array of mimetype strings to accept and only accpet (leave empty to ignore mimetypes)
  • maxSize: Number - The maximum size (in mb) the file can be. Defaults to 5
  • uploadDir: String - A location you'd like to write uploaded files too, leave blank to not upload files

Usage

const { router, response, methods} = require('octoris')
const multipart = require('@octoris/multipart')

function uploadHandler (ctx) {
  console.log(ctx.files) // => files array
  console.log(ctx.body) // => fields for body

  return response.send(200, 'Okay!')
}

const home = router.route(['/'], [methods.POST(handler)])

router.composeRoutes({}, [home], multipart({ uploadDir: './tmp' }))
0.3.0

2 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago