欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

MongoDB

程序员文章站 2022-06-08 15:53:33
...

MongoDB - GridFS源码分析,这是官网的一段GridFS的介绍. GridFS是提供了把一个大文件切分成多个document来存储的. 向GridFS中插

The database supports native storage of binary data within BSON objects. However, BSON objects in MongoDB are limited in size (4MB older versions, 16MB in v1.7/1.8, higher limits in the future). The GridFS spec provides a mechanism for transparently dividing a large file among multiple documents. This allows us to efficiently store large objects, and in the case of especially large files, such as videos, permits range operations (e.g., fetching only the first N bytes of a file).

这是官网的一段GridFS的介绍. GridFS是提供了把一个大文件切分成多个document来存储的. 向GridFS中插入一个文件, 默认使用fs.files和fs.chunks两个collection来存储此文件的信息的, 其中fs.files存放了文件的信息, fs.chunks存放了文件的数据.

下面看具体测试代码:

MongoDB