gridfs-extra

Home > gridfs-extra > readFileWithStream

readFileWithStream() function

readFileWithStream reads a file from gridFS bucket using the provided stream

Signature:

declare function readFileWithStream(downloadStream: mongodb.GridFSBucketReadStream): Promise<Buffer>;

Parameters

Parameter Type Description
downloadStream mongodb.GridFSBucketReadStream The stream to download file from mongodb

Returns:

Promise<Buffer>

returns a promise that resolves to a Buffer

Example

const stream = bucket.openDownloadStreamByName(“example.txt”) ; const buffer = await readFileWithStream(stream) ;