Download/Upload files using GridFS on AWS Lambda with Node.js

Hi

I am porting my express node.js API to AWS Lambda and I am currently stuck by reading and writing files to mongoDB GridFS. The data I would like to store is mostly images and PDF documents.

Somehow I can not get the piping of the stream to work.

This is how I did it before

const getImage = (req: any, res: Response) => {
        gridfsBucket.openDownloadStreamByName(filename).pipe(res);
}

Does anyone have any hints on how to use GridFS on Lambda?

Is piping/streaming not supported on AWS Lambda? Can I download the whole stream inside the lambda and return this object?

Cheers! Marc