Skip to content

Instantly share code, notes, and snippets.

@alvesjnr
Created April 27, 2011 16:41
Show Gist options
  • Save alvesjnr/944629 to your computer and use it in GitHub Desktop.
Save alvesjnr/944629 to your computer and use it in GitHub Desktop.
Attaching files in couchdb with couchdbkit
#Example: attaching file using couchdbkit
import couchdbkit
f = open('/tmp/file') #it works if you have a file with this name dude!
doc = {'text':'My Attachment'}
s = couchdbkit.Server()
db = s.get_or_create_db('blah')
doc_id = db.save_doc(doc)['id']
db.put_attachment(doc, f, 'name of the file')
print db.get(doc_id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment