m4nuC / async-busboy

Promise based multipart form parser for KoaJS
MIT License
167 stars 58 forks source link

Updated docs about custom onFile handler. #30

Closed twentyrogersc closed 6 years ago

twentyrogersc commented 6 years ago

This addresses #29, where the documentation for onFile is incorrect - filePromises are not passed as an arg to a custom onFile handler.


Happy to add documentation for how to add a custom filePromises, however I felt that this may overcomplicate/confuse initial readers - thoughts?

async function(ctx, next) {
  const files = []
  const { fields } = await asyncBusboy(ctx.req, {
    onFile: function(fieldname, file, filename, encoding, mimetype) {
      files.push(uploadFilesToS3(file));
    }
  });

  const uploads = await Promise.all(files)
  if ( !validate(fields, uploads) ) {
    return 'error';
  }
}
codecov-io commented 6 years ago

Codecov Report

Merging #30 into master will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #30   +/-   ##
=======================================
  Coverage   93.81%   93.81%           
=======================================
  Files           1        1           
  Lines          97       97           
  Branches       11       11           
=======================================
  Hits           91       91           
  Misses          6        6

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9358211...b320999. Read the comment docs.

m4nuC commented 6 years ago

Thank you @twentyrogersc !