1
# [SNIPPET_NAME: Add an attachment to a Desktopcouch Record]
2
# [SNIPPET_CATEGORIES: DesktopCouch]
3
# [SNIPPET_DESCRIPTION: Shows how to add an attachment to a Desktopcouch Record that will be stored and replicated by CouchDB]
4
# [SNIPPET_AUTHOR: Manuel de la Pena <mandel@themacaque.com>]
5
# [SNIPPET_DOCS: http://www.themacaque.com/wiki/doku.php?id=desktopcouch:create_attachments]
6
# [SNIPPET_LICENSE: GPL]
8
from desktopcouch.records.record import Record
9
from desktopcouch.records.server import CouchDatabase
11
# get the jpg to add from the command line
15
db = CouchDatabase("addattachment", create=True)
16
record = Record(record_type="url")
17
record.attach(path, "blob", "image/jpg")
20
print "Please pass the path of the jpg to add."
22
# got to /home/$USER/.local/share/desktop-couch/couchdb.html to see the