mongoose-gridfs-extra

Home > mongoose-gridfs-extra > writeFileByName

writeFileByName() function

readFileByName stores file into gridFS bucket by fileName

Signature:

declare function writeFileByName(bucket: mongo.GridFSBucket, file: Buffer, fileName: string, options?: mongo.GridFSBucketWriteStreamOptions | undefined): Promise<mongo.GridFSFile>;

Parameters

Parameter Type Description
bucket mongo.GridFSBucket a mongodb gridFS bucket
file Buffer the file to save into mongodb bucket
fileName string name of file to store
options mongo.GridFSBucketWriteStreamOptions | undefined (Optional) options for opening download stream

Returns:

Promise<mongo.GridFSFile>

a promise that resolves to a GridFSFile

Exceptions

Error