想要将ZIP文件存储在我的MongoDB数据库中,它们超过16 MB 我尝试使用mongoose-gridfs,但无法取回文件
mongoose.connect('mongodb://localhost:27017/cache').then(() => {
const { model: Attachment } = gridfs({
collection: 'attachments',
model: 'Attachment',
mongooseConnection: mongoose.connection
});
const readStream = fs.createReadStream('./test.zip');
const options = ({ filename: 'cache.zip', contentType: 'application/zip' });
Attachment.write(options, readStream, (error, file) => console.log(error,file) );
});
例如,它返回一个对象ID-5cc2d68d9572233b3004952a 但后来我尝试获取该文件
Attachment.readById('5cc2d68d9572233b3004952a', (err, buffer ) => console.log(buffer));
我没有定义
在我的MongoDB中(屏幕) attachment chunks attachemnt files