better attachment api

This commit is contained in:
Chris Anderson 2008-06-07 09:00:41 -07:00
parent bf1acd8355
commit b350a51963
2 changed files with 10 additions and 4 deletions

View file

@ -66,8 +66,8 @@ class CouchRest
result = {}
attachments.each do |k,v|
result[k] = {
"type" => "base64",
"data" => base64(v)
"type" => v['type'],
"data" => base64(v['data'])
}
end
result

View file

@ -190,7 +190,10 @@ describe CouchRest::Database do
"_id" => "mydocwithattachment",
"field" => ["some value"],
"_attachments" => {
"test.html" => @attach
"test.html" => {
"type" => "text/html",
"data" => @attach
}
}
}
@db.save(@doc)
@ -211,7 +214,10 @@ describe CouchRest::Database do
@doc = {
"field" => ["some other value"],
"_attachments" => {
"http://example.com/stuff.cgi?things=and%20stuff" => @attach
"http://example.com/stuff.cgi?things=and%20stuff" => {
"type" => "text/html",
"data" => @attach
}
}
}
@docid = @db.save(@doc)['id']