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:
Johannes J. Schmidt 2010-01-29 20:00:06 +01:00 committed by Marcos Tapajós
parent dad7e349a7
commit a7ee95b33c

View file

@ -14,7 +14,7 @@ module CouchRest
# reads the data from an attachment # reads the data from an attachment
def read_attachment(attachment_name) def read_attachment(attachment_name)
Base64.decode64(database.fetch_attachment(self, attachment_name)) database.fetch_attachment(self, attachment_name)
end end
# modifies a file attachment on the current doc # modifies a file attachment on the current doc
@ -52,10 +52,6 @@ module CouchRest
private private
def encode_attachment(data)
::Base64.encode64(data).gsub(/\r|\n/,'')
end
def get_mime_type(file) def get_mime_type(file)
::MIME::Types.type_for(file.path).empty? ? ::MIME::Types.type_for(file.path).empty? ?
'text\/plain' : MIME::Types.type_for(file.path).first.content_type.gsub(/\//,'\/') 'text\/plain' : MIME::Types.type_for(file.path).first.content_type.gsub(/\//,'\/')