これは、gridfs-streamまたはそれが使用する基盤となるネイティブmongodbドライバーでは十分に文書化されていませんが、その方法は次のとおりです。
これがoptionsです gridfs-stream createWriteStreamからのオブジェクト 例
(rootに注意してください オプション):
{
_id: '50e03d29edfdc00d34000001',
filename: 'my_file.txt',
mode: 'w',
chunkSize: 1024,
content_type: 'plain/text',
root: 'my_collection', // Bucket will be 'my_collection' instead of 'fs'
metadata: {
...
}
}
機能する理由:
gridfs-streamはoptionsを通過します createWriteStreamへの呼び出しを渡すオブジェクト またはcreateReadStream 基盤となるmongodbドライバーに移動して、gridStoreを作成します ファイルを表すオブジェクト。次に、mongodbドライバー rootを認識します optionsで オブジェクト
デフォルトの「fs」グリッドバケットプレフィックス文字列のオーバーライドとして。