fixed extended attachment encoding part 2
encoding was done twice, once while setting attachment and once while saving the document. Also the attachment was decoded while retreaving, but this is done by CouchDB itself automatically, as described in http://wiki.apache.org/couchdb/HTTP_Document_API#line-463. Signed-off-by: Marcos Tapajós <tapajos@gmail.com>
This commit is contained in:
parent
dad7e349a7
commit
a7ee95b33c
|
@ -14,7 +14,7 @@ module CouchRest
|
|||
|
||||
# reads the data from an attachment
|
||||
def read_attachment(attachment_name)
|
||||
Base64.decode64(database.fetch_attachment(self, attachment_name))
|
||||
database.fetch_attachment(self, attachment_name)
|
||||
end
|
||||
|
||||
# modifies a file attachment on the current doc
|
||||
|
@ -52,10 +52,6 @@ module CouchRest
|
|||
|
||||
private
|
||||
|
||||
def encode_attachment(data)
|
||||
::Base64.encode64(data).gsub(/\r|\n/,'')
|
||||
end
|
||||
|
||||
def get_mime_type(file)
|
||||
::MIME::Types.type_for(file.path).empty? ?
|
||||
'text\/plain' : MIME::Types.type_for(file.path).first.content_type.gsub(/\//,'\/')
|
||||
|
|
Loading…
Reference in a new issue