async-busboy-plus

Promise based multipart form parser

Usage no npm install needed!

<script type="module">
  import asyncBusboyPlus from 'https://cdn.skypack.dev/async-busboy-plus';
</script>

README

Promise Based Multipart Form Parser

forked from 'async-busboy'

add complete method to delete tmpfile

add tmpdir option to select where to cache

Examples

Async/Await (using temp files)

import asyncBusboy from 'async-busboy-plus';

// Koa 2 middleware
async function(ctx, next) {
  const {files, fields, complete} = await asyncBusboy(ctx.req, {
    // default to os.tmpdir
    tmpdir: '/tmp'
  });

  // Make some validation on the fields before upload to S3
  if ( checkFiles(fields) ) {
    files.map(uploadFilesToS3)
  } else {
    return 'error';
  }
  complete()
}