Home > mongoose-gridfs-extra > readFileWithStream
readFileWithStream reads a file from gridFS bucket using the provided stream
Signature:
declare function readFileWithStream(downloadStream: mongo.GridFSBucketReadStream): Promise<Buffer>;
| Parameter | Type | Description |
|---|---|---|
| downloadStream | mongo.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) ;