Seemingly basic MongoDB GridFS commands...that I cannot find
gridfs, mongodb
Solution
From command line you can use mongofiles: http://www.mongodb.org/display/DOCS/GridFS+Tools
mongofiles put yourfile.txt
cd /tmp
mongofiles get yourfile.txt
The first line puts the file yourfile.txt to the mongodb. The second one retrieves it at another position in the file system.
I think it is not possible to use GridFS directly from the mongo shell.
From python you can use:
class gridfs.GridFS(database, collection='fs')
http://api.mongodb.org/python/current/api/gridfs/index.html#gridfs.GridFS
For what GridFS should be used:
http://www.mongodb.org/display/DOCS/When+to+use+GridFS
Problem
How, through the mongo shell, do I "upload" a file to my MongoDB and how to I retrieve that same file? I wonder, what is the output, even, after doing so. I think showing what I've done will show how foolish my attempts have been. ``` db.fs.files.insert("foo.txt"); ``` This just seems to insert the actual text not the document I want...and to retrieve, I found that ``` db.fs.files.retrieve() ``` Isnt a function. find() just displays to me...but I want the actual document's contents printed, whether it be BINARY data or w/e I don't care, haha. I'm sorry for such miserable attempts - but perhaps it showcases how little I know of what GridFS can do - maybe someone can clear that up for me in addition to the usage.