Pymongo and gridfs

MongoDB’s GridFS is a specification for storing and retrieving files that exceed the BSON-document size limit of 16MB.

You could use Pymongo to easily store files to MongoDB GridFS like this:

<pre> import gridfs fs = gridfs.GridFS(settings.DB) file_id = fs.put(f) print 'save file to GridFS:{}'.format(file_id) </pre>

By default, GridFS uses two collections to store files with names prefixed by fs bucket:

You can choose a different bucket name than fs, and create multiple buckets in a single database.

References: