@octoris/multipart

0.3.0 • Public • Published

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' }))

Package Sidebar

Install

npm i @octoris/multipart

Weekly Downloads

2

Version

0.3.0

License

ISC

Unpacked Size

7.2 kB

Total Files

6

Last publish

Collaborators

  • killparadise