Home > gridfs-extra > readFileById
readFileById returns Buffer read from specified file stored in mongodb bucket by objectId
Signature:
declare function readFileById(bucket: mongodb.GridFSBucket, id: mongodb.ObjectId, options?: mongodb.GridFSBucketReadStreamOptionsWithRevision | undefined): Promise<Buffer>;
| Parameter | Type | Description |
|---|---|---|
| bucket | mongodb.GridFSBucket | a mongodb gridFS bucket |
| id | mongodb.ObjectId | objectId of file to read |
| options | mongodb.GridFSBucketReadStreamOptionsWithRevision | undefined | (Optional) options for opening download stream |
Returns:
Promise<Buffer>
a promise that resolves to a Buffer