{"id":18141,"library":"aws-multipart-parser","title":"aws-multipart-parser","description":"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.","status":"active","version":"0.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/vivasvan/aws-multipart-parser","tags":["javascript","aws","lambda","multipart","multipart/form-data","multipart/formdata","form-data","formdata","parser","typescript"],"install":[{"cmd":"npm install aws-multipart-parser","lang":"bash","label":"npm"},{"cmd":"yarn add aws-multipart-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add aws-multipart-parser","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Library is ESM-first; CommonJS require still works but tree-shaking may be affected.","wrong":"const parse = require('aws-multipart-parser').parse","symbol":"parse","correct":"import { parse } from 'aws-multipart-parser'"},{"note":"Default export is the parse function itself; named import is preferred for clarity.","wrong":"const awsMultipartParser = require('aws-multipart-parser')","symbol":"default","correct":"import awsMultipartParser from 'aws-multipart-parser'"},{"note":"Type import for TypeScript users; not available as a runtime export.","wrong":null,"symbol":"ParsedFormData","correct":"import type { ParsedFormData } from 'aws-multipart-parser'"},{"note":"CommonJS pattern works but some bundlers may optimize poorly.","wrong":"const parse = require('aws-multipart-parser');","symbol":"parse","correct":"const { parse } = require('aws-multipart-parser')"}],"quickstart":{"code":"import { parse } from 'aws-multipart-parser';\n\nexport const handler = async (event) => {\n  try {\n    const formData = parse(event, true);\n    console.log('Parsed fields:', formData.fields);\n    console.log('Parsed files:', formData.files);\n    return {\n      statusCode: 200,\n      body: JSON.stringify({ message: 'Success', data: formData }),\n    };\n  } catch (error) {\n    return {\n      statusCode: 400,\n      body: JSON.stringify({ error: 'Failed to parse request', details: error.message }),\n    };\n  }\n};","lang":"typescript","description":"Shows how to import and use the parse function in an AWS Lambda handler, including error handling and TypeScript integration."},"warnings":[{"fix":"Add 'multipart/form-data' to API Gateway binary media types, or use serverless-apigw-binary plugin.","message":"API Gateway binary support must be enabled (multipart/form-data) or parsing will fail silently or return empty results.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Always pass true as second argument to force parsing, or ensure proper boundary in headers.","message":"The second parameter 'force' defaults to false; if false, the parser only works when Content-Type includes boundary. Missing boundary causes parse failure.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Migrate to aws-multipart-parser for TypeScript support and bug fixes.","message":"The parent library (myshenin/aws-lambda-multipart-parser) is no longer maintained; this fork is the recommended replacement.","severity":"deprecated","affected_versions":""},{"fix":"Use Buffer.from(fileValue, 'base64') to get binary data for further processing.","message":"File fields are returned as strings (base64) rather than Buffer; binary data processing requires decoding.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure API Gateway is configured to pass headers, or invoke lambda with proper multipart request.","cause":"Event object missing 'headers' property or 'Content-Type' header without boundary.","error":"TypeError: Cannot read properties of undefined (reading 'split')"},{"fix":"Enable binary media types on API Gateway, specifically 'multipart/form-data'.","cause":"API Gateway binary support not enabled for multipart/form-data.","error":"Parsed form data is empty but request contains form fields"},{"fix":"Update to aws-multipart-parser@0.2.1 and import type { ParsedFormData }.","cause":"TypeScript type mismatch; older versions may not include type exports.","error":"Property 'type' does not exist on type 'ParsedFormData'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}