I'm glad to see AWS now supports multipart/form-data on AWS Lambda, but now that the raw data is in my lambda function how do I process it?
I see multiparty is a good multipart library in Node for multipart processing, but its constructor expects a request, not a raw string.
The input message I am receiving on my Lambda function (after the body mapping template has been applied) is:
{ "rawBody": "--ce0741b2-93d4-4865-a7d6-20ca51fe2689
Content-Disposition: form-data; name="Content-Type"
multipart/mixed; boundary="------------020601070403020003080006"
--ce0741b2-93d4-4865-a7d6-20ca51fe2689
Content-Disposition: form-data; name="Date"
Fri, 26 Apr 2013 11:50:29 -0700
--ce0741b2-93d4-4865-a7d6-20ca51fe2689
Content-Disposition: form-data; name="From"
Bob <[email protected]>
--ce0741b2-93d4-4865-a7d6-20ca51fe2689
Content-Disposition: form-data; name="In-Reply-To"
...
etc and some file data.
The body mapping template I'm using is
{
"rawBody" : "$util.escapeJavaScript($input.body).replaceAll("\'", "'")"
}
How can I parse this data to acecss the fields and files posted to my Lambda function?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…