The PyMongo driver provides a package, gridfs, that provides support for GridFS from a programming context. The core class is gridfs.GridFS. There are a number of supporting packages, however, in order to retain our focus on the essentials, we concentrate here only on the core class. GridFS class methods mirror the commands discussed in the previous subsection. The following table provides a summary of the more important methods:
gridfs.GridFS.method | Notes |
find(*args, **kwargs) | This method operates in a similar manner to pymongo.collection.find(). *args is a JSON document with key/value pairs. The key can be anything in the fs.files collection. The most common key is filename. **kwargs is a series of key-value keypairs including the keys filter, skip, limit, no_cursor_timeout and sort. find_one() takes the same arguments except only a single file is returned. |
list() | Operates much like the mongofiles list command. It returns a list of... |