MongoDB – GridFS source code analysis, this is an introduction to GridFS from the official website. GridFS provides the ability to split a large file into multiple documents for storage. Insert into 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 piding 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).
This is an introduction to GridFS from the official website. GridFS provides the ability to split a large file into multiple documents for storage. When inserting a file into GridFS, two collections, fs.files and fs.chunks, are used by default for storage. The information of this file, fs.files stores the file information, and fs.chunks stores the file data.
Let’s look at the specific test code:
,