Home > gridfs-extra > readFileWithStream
readFileWithStream reads a file from gridFS bucket using the provided stream
Signature:
declare function readFileWithStream(downloadStream: mongodb.GridFSBucketReadStream): Promise<Buffer>;
Parameter | Type | Description |
---|---|---|
downloadStream | mongodb.GridFSBucketReadStream | The stream to download file from mongodb |
Returns:
Promise<Buffer>
returns a promise that resolves to a Buffer
const stream = bucket.openDownloadStreamByName(“example.txt”) ; const buffer = await readFileWithStream(stream) ;