lib/couchrest/mixins/extended_attachments.rb in couchrest-0.34 vs lib/couchrest/mixins/extended_attachments.rb in couchrest-0.35

- old
+ new

@@ -12,11 +12,11 @@ raise ArgumentError, 'You must specify :file and :name' end # 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 def update_attachment(args={}) raise ArgumentError unless args[:file] && args[:name] @@ -50,25 +50,21 @@ "#{database.uri}/#{self.id}/#{attachment_name}" end 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(/\//,'\/') end def set_attachment_attr(args) content_type = args[:content_type] ? args[:content_type] : get_mime_type(args[:file]) self['_attachments'][args[:name]] = { 'content_type' => content_type, - 'data' => encode_attachment(args[:file].read) + 'data' => args[:file].read } end end # module ExtendedAttachments end -end \ No newline at end of file +end