I have parsed a file using lambda-multipart-parser and got results like this and my code is
let result = await parser.parse(event);
let a= (result.files[0].content);
and o/p is
{
"type": "Buffer",
"data": [
65,
99,
99,
111,
117,
110,
116,
110,
117,
109,
98,
101,
114,
44,
85,
115,
101,
114,
110,
97,
109,
101,
44,
80,
97,
115,
115,
119,
111,
114,
100,
44,
76,
99,
111,
110,
97,
109,
101,
44,
83,
116,
97,
116,
117,
115 ]}
so to get data if i give
let a= (result.files[0].content.data);
I am getting output blank(i.e 1 in postman)
CodePudding user response:
Even thought result.files[0].content
is written out as a plain object, it is actually a Buffer
object. So you'll have to use one of the methods on the object to retrieve the information, e.g., result.files[0].content.toString('utf-8')
to get the UTF-8 string represented by the buffer.