better attachment api
This commit is contained in:
parent
bf1acd8355
commit
b350a51963
2 changed files with 10 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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']
|
||||
|
|
Loading…
Reference in a new issue