Gridfs is a specification for storing large files in MongoDB. All officially supported drivers have implemented the gridfs specification.
Basic Principles
The Database supports binary data storage in bson object format. However, in MongoDB, The bson object size is limited (4 MB in the old version and 16 Mb in v1.7/1.8, which will be higher in the future ). The gridfs specification provides a mechanism to transparently split a large file into multiple small documents. This allows us to efficiently store large objects, especially large files, such as videos, and range operations (such as obtaining the first n Bytes of a file ).
Implementation
To achieve this, this specification specifies a standard that can block files. Each file has a metadata object in the collection, and one or more block objects in the block set. For more detailed information, you can query the gridfs specification. However, you do not need to read it. You only need to take a look at the gridfs API or javasfile Tool Driven by each language.
Language Support
Most drivers contain gridfs implementations. For languages not listed below, check the driver's API documentation. (If gridfsas is not supported in this language, check the gridfs specifications. It is not difficult to implement the gridfs processing function)
Command line tool
The command line tool can be used to read/write gridfs files from MongoDB to the local file system.