getEventBodyAsBuffer
@h4ad/serverless-adapter > getEventBodyAsBuffer
(function) getEventBodyAsBuffer
Get the event body as buffer from body string with content length
Signature:
export declare function getEventBodyAsBuffer(body: string, isBase64Encoded: boolean): [body: Buffer, contentLength: number];
Parameters
Parameter | Type | Description |
---|---|---|
body | string | The body string that can be encoded or not |
isBase64Encoded | boolean | Tells if body string is encoded in base64 |
Returns:
[body: Buffer, contentLength: number]
Example
const body = '\{}';
const [buffer, contentLength] = getEventBodyAsBuffer(body, false);
console.log(buffer);
// <Buffer 7b 7d>
console.log(contentLength);
// 2