时间:2021-07-01 10:21:17 帮助过:2人阅读
使用mongofile来操作GridFS:
1 //将 “aaaa” 写入foo.txt文件中 2 c:\MongoDB\mongodb_win32_x86_64_2.2.7\bin>echo "aaaa" > foo.txt 3 //将foo.txt保存到GridFS中 4 c:\MongoDB\mongodb_win32_x86_64_2.2.7\bin>mongofiles.exe put foo.txt 5 connected to: 127.0.0.1 6 added file: { _id: ObjectId(‘53449f0becdebde54ff76105‘), filename: "foo.txt", ch 7 unkSize: 262144, uploadDate: new Date(1397006091696), md5: "819596956779801cced4 8 fb21379bf023", length: 9 } 9 done! 10 //查看 11 c:\MongoDB\mongodb_win32_x86_64_2.2.7\bin>mongofiles.exe list 12 connected to: 127.0.0.1 13 foo.txt 9 14 //获取 15 c:\MongoDB\mongodb_win32_x86_64_2.2.7\bin>mongofiles.exe get foo.txt 16 connected to: 127.0.0.1 17 done write to: foo.txt
命令说明
put:将文件系统中的一个文件添加到GridFS
list:会把所有添加到GridFS中的文件列出来
get:put的反向操作
在mongodb工具中查看GridFS
MongoDB_GridFS_存储文件
标签: