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