Mongodb-gridfs Large File system

Source: Internet
Author: User
Tags md5

Gridfs is a mechanism for storing a binary file in MongoDB, using Gridfs for the following reasons:

1, storage of huge files (video pictures).

2, the use of Gridfs can simplify the demand.

3, GRIDFS using the already established replication and fragmentation mechanism, fault recovery and expansion are very easy.

4, Gridfs can avoid users to upload files system problems.

5, do not produce this piece of debris.

Summary: Gridfs uses two tables to store data: Files contains metadata objects, and chunks contains some other related binary blocks.

In order for multiple grdifs to be named a single database file with a block with a prefix, the default is FS, which contains Fs.files and fs.chunks. Various other third-party languages can change the prefix.

Introduction to use: directory containing mongofile files into the bin

For example:

/usr/local/mongodb/mongofiles put'/home/timeless/Desktop/More than 2000 domain names'-U Root-penter password:connected to:127.0.0.1added file: {_id:objectid ('550d5ae73c11b4f50c88c99e'), FileName:"/home/timeless/Desktop/More than 2000 domain names", ChunkSize:261120, Uploaddate:NewDate (1426938599982), MD5:"025141eb3b856cb1d05f51c8b1fac3ec", Length: +}done!
Login MONGO >/usr/local/mongodb/mongo-uroot-pmongodb Shell version:2.6.6Enter password:connecting to:test>Show Collectionsfs.chunksfs.filespersonstockssystem.indexes>Db.fs.files.find () {"_id": ObjectId ("550d5ae73c11b4f50c88c99e"),"filename":"/home/timeless/Desktop/More than 2000 domain names","chunkSize":261120,"uploaddate": Isodate ("2015-03-21t11:49:59.982z"),"MD5":"025141eb3b856cb1d05f51c8b1fac3ec","length": + }>Db.fs.chunks.find () {"_id": ObjectId ("550d5ae7e67b9f05743cdc35"),"files_id": ObjectId ("550d5ae73c11b4f50c88c99e"),"N":0,"Data": Bindata (0,"d2hvaxmgchjpdmfjesbwcm90zwn0aw9uihnlcnzpy2ugynkgdmfsdwutzg9tywluicagioazqowgjos6ugo=") }>

List the current file information

[Email protected]:~$/usr/local/mongodb/mongofiles list  -u root-127.0.  0.1/home/timeless/Desktop/More than 2000 domain name    [email protected]

Download the current file

get /home/timeless/desktop/More than 2000 domain name  -u root-127.0.  0.1/home/timeless/Desktop/more than 2000 domain names

Delete the specified file

[Email protected]:~$/usr/local/mongodb/mongofiles Delete  /home/timeless/desktop/More than 2000 domain  -u  root- 127.0. 0.1 Done! [email protected]-hp-pavilion-g4-notebook-pc:~$

Mongodb-gridfs Large 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.