Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

GridFS of MongoDB

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Big data's storage (such as pictures, music, all kinds of binary data) is supported in MongoDB, but this practice needs to be handled by the user themselves, using the "mongofiles" command.

1. Use the command line to enter the path made by the picture

[root@D2-LZY245 ~] # cd / root/

2. Save the file to the vault

[root@D2-LZY245 ~] # mongofiles put Tulips.jpg

2017-08-17T11:01:24.787+0800 connected to: localhost

Added file: Tulips.jpg

At this point, the binary data to be saved is written to the database.

3. View saved files

[root@D2-LZY245 ~] # mongofiles list

2017-08-17T11:02:56.059+0800 connected to: localhost

Tulips.jpg 620888

4. There is a system collection of fs in MongoDB, which is saved under the test database by default.

Example: view saved information

> use test

Switched to db test

> show collections

Fs.chunks

Fs.files

> db.fs.files.find ()

{"_ id": ObjectId ("599507041764d541df4535ce"), "chunkSize": 261120, "uploadDate": ISODate ("2017-08-17T03:01:24.798Z"), "length": 620888, "md5": "fafa5efeaf3cbe3b23b2748d13e629a1", "filename": "Tulips.jpg"}

5. Delete files

[root@D2-LZY245 ~] # mongofiles delete Tulips.jpg

2017-08-17T11:07:46.001+0800 connected to: localhost

Successfully deleted all instances of 'Tulips.jpg' from GridFS

Binary data storage is supported in MongoDB, but it doesn't make much sense to exist. Basically not used in the project.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report