Nodejs Lambda Streaming Response

Viewed 159

If I want to stream file to lambda output (writing client response to http for example,) how is that done? An example I thought of:

// lambda nodejs handler.ts
import { createReadStream, createWriteStream } from 'fs';

export const index = async (event: any, context: any, callback: any) => {
  const rs = createReadStream('./file.json');
  const ws = createWriteStream('some-lambda-output???');

  rs.pipe(ws).on('error', callback);
};
0 Answers
Related