Registry / aws / aws-multipart-parser

aws-multipart-parser

JSON →
library0.2.1jsnpmunverified

A lightweight parser for multipart/form-data requests in AWS Lambda environments. Version 0.2.1 provides typed output and supports binary file data, addressing limitations of the parent library myshenin/aws-lambda-multipart-parser. Released as needed, it is a dependency-free utility requiring API Gateway binary support configuration. Differentiates with TypeScript types and explicit handling of binary fields, unlike alternatives that may lack type safety or ignore binary content.

npm install aws-multipart-parser
INSTALL
IMPORT
SIG · AWS-MULTIPART-PARS
A
aws-multipart-parser
awsjavascriptv0.2.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parse
import { parse } from 'aws-multipart-parser'
const parse = require('aws-multipart-parser').parse
Library is ESM-first; CommonJS require still works but tree-shaking may be affected.
default
import awsMultipartParser from 'aws-multipart-parser'
const awsMultipartParser = require('aws-multipart-parser')
Default export is the parse function itself; named import is preferred for clarity.
ParsedFormData
import type { ParsedFormData } from 'aws-multipart-parser'
Type import for TypeScript users; not available as a runtime export.
parse
const { parse } = require('aws-multipart-parser')
const parse = require('aws-multipart-parser');
CommonJS pattern works but some bundlers may optimize poorly.

Shows how to import and use the parse function in an AWS Lambda handler, including error handling and TypeScript integration.

import { parse } from 'aws-multipart-parser'; export const handler = async (event) => { try { const formData = parse(event, true); console.log('Parsed fields:', formData.fields); console.log('Parsed files:', formData.files); return { statusCode: 200, body: JSON.stringify({ message: 'Success', data: formData }), }; } catch (error) { return { statusCode: 400, body: JSON.stringify({ error: 'Failed to parse request', details: error.message }), }; } };
Debug
Known issues
gotchaAPI Gateway binary support must be enabled (multipart/form-data) or parsing will fail silently or return empty results.
fix
Add 'multipart/form-data' to API Gateway binary media types, or use serverless-apigw-binary plugin.
affects: >=0.1.0
gotchaThe second parameter 'force' defaults to false; if false, the parser only works when Content-Type includes boundary. Missing boundary causes parse failure.
fix
Always pass true as second argument to force parsing, or ensure proper boundary in headers.
affects: >=0.1.0
deprecatedThe parent library (myshenin/aws-lambda-multipart-parser) is no longer maintained; this fork is the recommended replacement.
fix
Migrate to aws-multipart-parser for TypeScript support and bug fixes.
gotchaFile fields are returned as strings (base64) rather than Buffer; binary data processing requires decoding.
fix
Use Buffer.from(fileValue, 'base64') to get binary data for further processing.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'split')
Event object missing 'headers' property or 'Content-Type' header without boundary.
fix
Ensure API Gateway is configured to pass headers, or invoke lambda with proper multipart request.
Parsed form data is empty but request contains form fields
API Gateway binary support not enabled for multipart/form-data.
fix
Enable binary media types on API Gateway, specifically 'multipart/form-data'.
Property 'type' does not exist on type 'ParsedFormData'
TypeScript type mismatch; older versions may not include type exports.
fix
Update to aws-multipart-parser@0.2.1 and import type { ParsedFormData }.
Upgrade
Version history
0.2.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
54 hits · last 30 days
node
46
OpenAI (training)
1
Resources
aws-multipart-parser — npm install aws-multipart-parser · libregistry