Skip to content

This nodejs module will parse the multipart-form containing files and fields from the AWS lambda event object. It works very well parsing binary and text files.

License

Notifications You must be signed in to change notification settings

travelhawk/multipart-lambda-ts-v2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

multipart-lambda-ts-v2

Introduction

Parse multipart-form with this module for AWS Lambda. It supports files and fields using the lambda event object coming from AWS API Gateway. Works well parsing binary and text files.

This is a fork of francismeynard/lambda-multipart-parser which integrates the following changes:

  • Update busboy library to newest version (1.6.0)
  • Support for lambda payload format V2.0 (APIGatewayProxyEventV2)
  • Typescript support

Installation

npm install multipart-lambda-ts-v2

Description

@param {event} - an event containing the multipart-form in the body
@return {object} - a JSON object containing array of files and fields, sample below.

{
    files: [
        {
            filename: 'test.pdf',
            content: <Buffer 25 50 6f 62 ... >,
            contentType: 'application/pdf',
            encoding: '7bit',
            fieldname: 'uploadFile1'
        }
    ],
    field1: 'VALUE1',
    field2: 'VALUE2',
}

Usage

const parser = require('multipart-lambda-ts-v2');

const result = await parser.parse(event);
console.log(result.files);

Important Please make sure to enable the "Use Lambda Proxy integration" in API Gateway method Integration request.

If decided not to enable it for some reason, make sure to pass the required Lambda event parameters in Integration Request -> Mapping Templates section, such as body, headers and isBase64Encoded flag.

Test

npm run test

Releases / Changelogs

0.0.1 - Initial stable release.

0.0.2 - Updated readme. Added Usage and link to sample implementation.

1.0.0 - Formalized package release version. Add utf8 support.

1.0.1 - Added support for TypeScript typings.

1.1.0 - Added support for payload format V2.0. Updated Typescript bindings. Updated busboy to 1.6.0.

About

This nodejs module will parse the multipart-form containing files and fields from the AWS lambda event object. It works very well parsing binary and text files.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%