myshenin / aws-lambda-multipart-parser

Parser of multipart/form-data requests for AWS Lambda
MIT License
74 stars 38 forks source link

[feature request]Have boundary and body as parameters instead of event #27

Open secretshardul opened 4 years ago

secretshardul commented 4 years ago

Issue I faced

Hi and really great work building a multipart parser for Lambda. Once issue I have with this library is that it only accepts 'event' as a parameter. While good for Lambda proxy integration, this is unsuitable for Lambda Custom integration.

Suggested feature

On looking at the code I see that your library just needs 2 parameters from the event object- 'Content-Type' header (for extracting boundary) and body(contains encoded string). Instead of asking for event, we could ask for these two parameters from the user. You can keep the existing function as it is, while adding a new function which incorporates these features.

For example

const multipart = require('aws-lambda-multipart-parser');
let body = event["body"];
let contentType = event["content-type"];
let output = multipart.parse(body, contentType, true);

If you don't mind, I can make a PR and you can add me as a collaborator for this library.