Created
April 27, 2011 16:41
-
-
Save alvesjnr/944629 to your computer and use it in GitHub Desktop.
Attaching files in couchdb with couchdbkit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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