From 74d9204b1fa0d5f18180b09f8d6d19ce49a16d7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Rodr=C3=ADguez=20Telep=20/=20Michael=20Rodr=C3=AD?= =?UTF-8?q?guez-Torrent?= Date: Wed, 16 Nov 2011 13:01:24 +0000 Subject: [PATCH] Fix broken processing of incoming e-mail attachments --- app/models/emailer/incoming.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/models/emailer/incoming.rb b/app/models/emailer/incoming.rb index ab6c5d06e1..1c696f7f1c 100644 --- a/app/models/emailer/incoming.rb +++ b/app/models/emailer/incoming.rb @@ -221,7 +221,17 @@ def process_incoming(email) @body = strip_responses(@body).strip_tags.to_s.strip @subject = email.subject.to_s.gsub(REPLY_REGEX, "").strip @files = email.attachments || [] - + + # Format attachments for processing by Paperclip + @files.collect! do |attachment| + file = StringIO.new(attachment.decoded) + file.class.class_eval { attr_accessor :original_filename, :content_type } + file.original_filename = attachment.filename + file.content_type = attachment.mime_type + + file + end + Rails.logger.info "#{@user.name} <#{@user.email}> sent '#{@subject}' to #{@to}" end