2、將文件保存到文件庫之中 [root@D2-LZY245 ~]# mongofiles put Tulips.jpg 2017-08-17T11:01:24.787+0800 connected to: localhost added file: Tulips.jpg
此時會向數據庫里面寫入要保存的二進制數據。
3、查看保存的文件 [root@D2-LZY245 ~]# mongofiles list 2017-08-17T11:02:56.059+0800 connected to: localhost Tulips.jpg 620888
4、在MongoDB里面有一個fs的系統集合,這個集合默認保存在了test數據庫下。 范例:查看保存的信息 > 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、刪除文件 [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