-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Description
Hello
Am trying to POST the gzip form-data. After the library parses the data, Am not able to convert the buffer to string.
Below is the code am using for testing.
`const multipart = require('aws-lambda-multipart-parser');
var zlib = require('zlib');
exports.handler = function(event,context,callback){
console.log(event);
var buf = Buffer.from(event['body'], 'base64').toString();
console.log(buf)
var parsed = multipart.parse(event, true);
console.log(parsed);
var gbuf = parsed['payload']['content'];
var stringBuf = zlib.gunzipSync(buf);
console.log(stringBuf);
const response = {
statusCode: 200,
headers: {
"Access-Control-Allow-Origin": "*"
},
body: JSON.stringify({ name : 'kalyan' })
};
callback(null,response);
}`
below is output of parser
{ name: 'kalyan',
payload:
{ type: 'file',
filename: 'sample_payload.xml.gz',
contentType: 'application/x-gzip',
content: <Buffer 1f 8b 08 08 ef aa 47 5b 00 03 73 61 6d 70 6c 65 5f 70 61 79 6c 6f 61 64 2e 78 6d 6c 00 ec 5d 6b 73 e2 38 d6 fe be 55 ef 7f 48 f5 d7 61 07 c9 b2 7c 49 ... > } }
and below is error when i try to unzip the buffer in above content. It is failing at the below line.
var stringBuf = zlib.gunzipSync(buf);
Error: incorrect header check
at Zlib._handle.onerror (zlib.js:370:17)
at Gunzip.Zlib._processChunk (zlib.js:540:30)
at zlibBufferSync (zlib.js:239:17)
at Object.exports.gunzipSync (zlib.js:175:10)
at exports.handler (/var/task/index.js:19:26)
Metadata
Metadata
Assignees
Labels
No labels