freesoftwarefactory / parse-multipart

A javascript/nodejs multipart/form-data parser which operates on raw data.
MIT License
48 stars 80 forks source link

I get an empty array #15

Closed davidgatti closed 5 years ago

davidgatti commented 6 years ago

Hello,

When I pass this for example:

Content-Disposition: form-data; name="from"

h@example.com
--__X_PAW_BOUNDARY__
Content-Disposition: form-data; name="to"

e@example.com
--__X_PAW_BOUNDARY__
Content-Disposition: form-data; name="subject"

This is a test
--__X_PAW_BOUNDARY__
Content-Disposition: form-data; name="reply_to"

d@example.pl
--__X_PAW_BOUNDARY__
Content-Disposition: form-data; name="html"

<p>Hello</p>
--__X_PAW_BOUNDARY__
Content-Disposition: form-data; name="text"

Hello
--__X_PAW_BOUNDARY__
Content-Disposition: form-data; name="file"; filename="Screen Shot 2018-03-25 at 12.33.00 PM.png"
Content-Type: image/png

�PNG
\u001a
\u0000\u0000\u0000
IHDR\u0000\u0000\u0000\u000f\u0000\u0000\u0000\u000b\u0006\u0000\u0000\u0000�G�\\u0

I get back an empty array, any idea what could be the problem?

sean256 commented 5 years ago

Same here even for the simplest of bodys

rambabusaravanan commented 5 years ago

In case, if you're using it in lambda, body is expected to be encoded so you need to handle it like below.

  let body = event.body;
  if (event.isBase64Encoded) {
    console.log('body is base-64 encoded');
    body = Buffer.from(event.body, 'base64');
  }
tadiraman commented 5 years ago

hey,

I am having same issue. var parts = multipart.Parse(body, boundary);

parts is empty!?