Java from getting started to mastering--database article MONGO db Gridfs file system

Source: Internet
Author: User

I. Overview
Gridfs is a storage mechanism for MongoDB that is used to store large binary files.
Advantages:
1. Using Gridfs can simplify your stack. If you are already using MongoDB, you can use GRIDFS instead of a standalone file storage tool
2.GridFS automatically balances existing replications or automatic shards set for MongoDB, so it is easier to fail over or scale out the file store.
3. When used to store user uploaded files, Gridfs can resolve some other file system problems that may be encountered in a more leisurely manner.
4. In Gridfs, the concentration of file storage is very high, because MongoDB allocates data files in 2G units.
disadvantage:
1.GridFS performance is relatively low: Access files from MongoDB, Rather than accessing files directly from the file system
2. If you want to modify the document on the Gridfs, you can only delete the existing file, The entire document is then re-saved.
The
simplest way to use the GRIDFS is to use the Mongofiles tool, which is included in all MONGO DB distributions, and can be used to upload files, download files, view file lists, search for files, and delete files in Gridfs. Here's a demonstration for you.
second, the code demonstration.
2.1 Uploading a file
mongofiles-d foobar-l "E:\a.txt" put "a.txt"
2.2 Viewing a list of files
Db.fs.chunks.find () and Db.fs.files.find () store all file information for the file system
2.3 View All Files
mongofiles-d foobar List
2.4 Deleting a file that exists
mongofiles-d foobar Delete ' a.txt '
third, summary.
The
Gridfs system provides a very efficient system for us to store very large data files in MongoDB
.

Java from getting started to mastering--database article MONGO db Gridfs file system

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.