I''m quite new to Ruby and Rails. Now I''m stuck on a problem
with
receiving emails. Everything but attachments work just fine. I try to
save the attached file (jpeg) in a file.
I use a Windows XP system and use Outlook to send the mails.
My receive function looks like this:
class Receiver < ActionMailer::Base
def receive(email)
Post.create(:title => email.subject, :body => email.body, :created_at
=> Time.now)
email.parts.each do |part|
filename = "#{RAILS_ROOT}/public/post/image/test.jpg"
File.open(filename,File::CREAT|File::TRUNC|File::WRONLY,0644){ |f|
f.write(part.body)
}
end
end
The problem is that the saved file is not an exact copy of the original
file. I see the pattern below:
Original: .. 07 08 09 0A 0B FF ..
Saved: .. 07 08 09 0D 0A 0B FF ..
(All 0A are replaced with 0D 0A)
So, there is a problem with "line feeds" in the image data. But what
and
why? What can I do about it?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---