Skip to content

Instantly share code, notes, and snippets.

@mrkschan
Created May 13, 2010 05:50
Show Gist options
  • Save mrkschan/399544 to your computer and use it in GitHub Desktop.
Save mrkschan/399544 to your computer and use it in GitHub Desktop.
import pymongo, gridfs
conn = pymongo.Connection('localhost')
fs = gridfs.GridFS(conn.test)
fid = fs.put('hello', filename='1st')
fid
# ObjectId('4beb91f78caf495b3e000000')
fid2 = fs.put('hello 2', filename='2nd', _id=fid)
fid2
# ObjectId('4beb91f78caf495b3e000000')
fs.list()
# [u'1st']
fs.get(fid).read()
# 'hello'
fid3 = fs.put('hello 3', filename='1st', _id=fid)
fs.get(fid3).read()
# 'hello'
fs.list()
# [u'1st']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment