sigh why does everybody jump to GridFS?
Depending on the size of the images and the exact use case, I'd recommend to store the imagesdirectly in the DB (not via GridFS). Here's why:
File System
- Storing the images in the file system is proven to work well, but it's not trivial
- You will need a different backup system, failover, replication, etc. This can be tricky DevOps-wise
- You will need to create a smart directory structure which is a leaky abstraction, because different file systems have very different characteristics. Some have no problem storing 16k files in one folder, others start to choke at a mere 1k files. A common approach is to use a convention like
af/2c/af2c2ab3852df91.jpg
, where the foldersaf
and2c
are inferred from the file name (which itself might be a hash of the content for deduplication purposes).
GridFS
GridFS is made for storing large files, and for storing files in a very similar way to a file system. That comes with some disadvantages:
- For every file, you will need one
fs.file
and onefs.chunk
document. Chunking is totally required for large files, but if your files are below 256k on average, there's no real chunking going on (default chunk size is 256k). So when storing small files in GridFS, you get the overhead without the advantage. Bad deal. It also requires two queries instead of one. - It imposes a certain structure on your collection, for instance to have a 'file name'. It depends on the use case, but I often choose to use a hash as the id and store the hash in the user, for example. That deduplicates, is easy to implement, aligns beautifully with caching and doesn't require coming up with any convention. It's also very efficient because the index is a byte array.
Things might look different if you're operating a site for photographers where they can upload their RAW files or large JPEGs at 10MB. In that case, GridFS is probably a good choice. For storing user images, thumbnails, etc., I'd simply throw the image in its own document flat.
相关推荐
Swift library for making storing data in a SQLite database easy as pie.zip,Swift library for making storing data in a SQLite database simple and magic-free
Sample Application to Prepare HLv2 Messages for Storing in MySQL
Chapter 4 covers InfoCubes, which are multidimensional data structures used for storing and analyzing data in SAP BW. 1. **Types of InfoCubes**: An overview of different types of InfoCubes, including...
Copy-On-Write (COW): UML's efficient approach to storing filesystem changes In-depth discussion of User Mode Linux networking and security Centrally managing User Mode Linux instances, and ...
+ fixed bug with images in PDF export for OSX viewers + Added ability to set font charset to default in Style Editor - fixed duplex problem when printing several copies of the report - fixed problem ...
In terms of the database, MySQL provides a robust and scalable solution for storing and managing the surveillance footage and metadata. It allows for efficient querying and retrieval of information, ...
Extend your existing .NET reporting solutions with SAP Crystal Server for report object, user, and user group management. Utilize APIs for customizing server logon, user management and report ...
了解如何在 Matlab 中创建和存储符号变量。 我们将使用符号变量进行代数、微积分等计算。
Extend your existing .NET reporting solutions with SAP Crystal Server for report object, user, and user group management. Utilize APIs for customizing server logon, user management and report ...
This book covers a verity of topics, including in-memory data grid, highly available service grid, streaming (event processing for IoT and fast data) and in-memory computing use cases from high-...
Extend your existing .NET reporting solutions with SAP Crystal Server for report object, user, and user group management. Utilize APIs for customizing server logon, user management and report ...
这个名为"storing_paintbrush_in_accessdb"的项目似乎是一个利用Access进行数据存储的具体应用,可能是为了管理画笔(paintbrush)相关的产品信息或者业务流程。下面将详细解析这个压缩包中的潜在知识点: 1. **...
Extend your existing .NET reporting solutions with SAP Crystal Server for report object, user, and user group management. Utilize APIs for customizing server logon, user management and report ...
Accuracer is currently available for the Borland Delphi, C++Builder and Kylix development environments in Single-User (SU), Multi-User (MU) and Client/Server (CS) versions. Key Features: Client/...
It also details dozens of powerful techniques supported by mg, the authors' own system for compressing, storing, and retrieving text, images, and textual images. mg's source code is freely available ...
CImg is designed to be highly efficient and user-friendly, making it suitable for both novice and experienced developers working with image processing tasks. #### Main Features and Structures The ...
Extend your existing .NET reporting solutions with SAP Crystal Server for report object, user, and user group management. Utilize APIs for customizing server logon, user management and report ...