gridfs-extra

Home > gridfs-extra > writeFileById

writeFileById() function

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>;

Parameters

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

Exceptions

Error