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
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 ...
IDOC structure includes Status Record for storing status information of IDOC dispatch, Data Record for storing data into segments and its corresponding fields and Control Record has receiver and ...
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 中创建和存储符号变量。 我们将使用符号变量进行代数、微积分等计算。
+ 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 ...
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-...
Amazon Web Services in Action, Second Edition is a comprehensive introduction to computing, storing, and networking in the AWS cloud. Readers will find clear, relevant coverage of all the essential ...
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 ...
If you have experience in DevOps and ops backgrounds then this is the book for you. Previous experience with both the basics of running servers in production as well as creating and managing ...
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 ...
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 ...
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 ...
Amazon Web Services in Action introduces you to computing, storing, and networking in the AWS cloud. You'll start with a broad overview of AWS and learn how to spin-up servers manually and from the ...
This means that publicly available repositories are found unsuitable for storing certain specific images. This chapter has all the information required to set up and sustain private repositories. ...
商业编程-源码-access源代码 storing_paintbrush_in_accessdb.zip
Loading images from the internet 212 ■ Displaying images on the billboard 214 ■ Caching the downloaded image for reuse 216 9.4 Posting data to a web server 217 Tracking current weather: sending post...
├─dataset storing the corpped images │ └─Vladimir_Putin ├─examples show examples ├─facebank storing the raw/origin images │ └─Vladimir_Putin ├─models storing the pretrained models ├─...