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