Usually use MySql,
When Oracle does image storage, it directly uploads files to the server and stores them in a fixed directory on the hard disk, and only the path is stored in the table. Now use MongoDB, learn about MongoDB
GridFS. MongoDB
GridFS is a submodule of mongodb. Using GridFS can store files persistently based on mongodb. It also supports distributed applications (file distribution storage and reading). GridFS is a mongodb A tool for users to store large objects. For mongodb, BSON format data (document) storage has a size limit, the maximum is 16M. However, in actual system development, there is often a function of uploading pictures or files, and these files may be large in size ..We can use Gridfs to assist in the management of these files.
The file table of Mongo GFS is composed of table name.files and table name.chunks
Composition, the former is the composition of file information, the latter is the content of the file, and the two are associated with files_id through _id. GridFS will divide large file objects into multiple small chunks (file fragments), generally 256k/piece, and each chunk will be stored in the chunks collection as a document (document) of mongodb. The gridfs module will provide each The file creates chunks and files information. The actual content of each file is stored in chunks (binary data), and the meta data related to the file (filename, content_type, and user-defined attributes) will be stored in the files collection. files The documents in the collection are in BSON format, you can use mongodb’s index and other features, and of course you can do data analysis on files documents.
It is recommended that you consider using MongoDB GridFS if you have the following usage scenarios.
1) There are a large number of uploaded pictures (uploaded by users or published by the system itself, etc.)
2) The magnitude of files is growing rapidly, which may hit the query performance bottleneck of the file system of the stand-alone operating system, and even exceed the expansion range of the stand-alone hard disk.
3) File backup (not applicable to gridfs, which can also be done by third parties, but it is not very convenient), failover and repair of file system access..
4)
The index of the file, the storage needs to associate more metadata information besides the file itself (for example, not only storing the file, but also saving some custom information such as the publishing author/publishing time/file tag attribute of some files) and needs Indexed…
5) Based on 4), the classification of files is vague. If the file system of the operating system is used, the folder classification relationship is confused or cannot be classified..
6) The current system is based on the web, and the access to pictures is routed according to the rules of the url.. (Ordinary file system is also available)
7) The file size is small and numerous, and the files may be migrated/deleted, etc..
Introduction to the use of MongoDB and GridFS image storage
This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/introduction-to-the-use-of-mongodb-and-gridfs-image-storage/