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 = {} result = {}
attachments.each do |k,v| attachments.each do |k,v|
result[k] = { result[k] = {
"type" => "base64", "type" => v['type'],
"data" => base64(v) "data" => base64(v['data'])
} }
end end
result result

View file

@ -190,7 +190,10 @@ describe CouchRest::Database do
"_id" => "mydocwithattachment", "_id" => "mydocwithattachment",
"field" => ["some value"], "field" => ["some value"],
"_attachments" => { "_attachments" => {
"test.html" => @attach "test.html" => {
"type" => "text/html",
"data" => @attach
}
} }
} }
@db.save(@doc) @db.save(@doc)
@ -211,7 +214,10 @@ describe CouchRest::Database do
@doc = { @doc = {
"field" => ["some other value"], "field" => ["some other value"],
"_attachments" => { "_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'] @docid = @db.save(@doc)['id']