Too much MongoDB server memory usage when saving large file (3Gb) with GridFS. Help fix, please.
let uploadStream: GridFSBucketWriteStream
let readableUpload: Readable
uploadStream = bucket.openUploadStream(chunkName)
readableUpload = new Readable()
readableUpload.push(req.file?.buffer)
readableUpload.push(null)
readableUpload.pipe(uploadStream)
new Promise((resolve, reject) => {
uploadStream.on('finish', (g) => {
readableUpload.destroy();
resolve(g);
});
uploadStream.on('error', (error) => {
readableUpload.destroy();
reject(error);
});
readableUpload.on('error', (error) => {
uploadStream.destroy();
reject(error);
});
});