Home > gridfs-extra > writeFileById
readFileByName stores file into gridFS bucket by id
Signature:
declare function writeFileById(bucket: mongodb.GridFSBucket, id: mongodb.ObjectId, file: Buffer, fileName: string, options?: mongodb.GridFSBucketWriteStreamOptions | undefined): Promise<GridFSFile>;
Parameter | Type | Description |
---|---|---|
bucket | mongodb.GridFSBucket | a mongodb gridFS bucket |
id | mongodb.ObjectId | objectId of file to read |
file | Buffer | the file to save into mongodb bucket |
fileName | string | name of file to store |
options | mongodb.GridFSBucketWriteStreamOptions | undefined | (Optional) options for opening download stream |
Returns:
Promise<GridFSFile>
a promise that resolves to a GridFSFile
Error