Home > gridfs-extra > writeFileWithStream
writeFileWithStream store a file into gridFS bucket using the provided stream. This function will overwrite the
Signature:
declare function writeFileWithStream(uploadStream: mongodb.GridFSBucketWriteStream, file: Buffer): Promise<GridFSFile>;
Parameter | Type | Description |
---|---|---|
uploadStream | mongodb.GridFSBucketWriteStream | The stream to upload file to mongodb |
file | Buffer | the file to save into mongodb bucket |
Returns:
Promise<GridFSFile>
a promise that resolves to a GridFSFile
Error
const uploadStream = bucket.openUploadStream(“example.txt”) ; const gridFsFile = await writeFileWithStream(uploadStream, file) ;