I am trying to save an email attachment as a blob to the db. I''m trying to it within our existing framework which uses RMagick to read the image as a blob. When it does this I get a "JPEG datastream contains no image" error. Here is my code. // Handles receiving the email class AssetSubmitHandler < ActionMailer::Base def receive(email) if email.has_attachments? email.attachments.each do |attachment| img = Photo.create(:original_data => attachment) asset = Asset.create(:user_id => 2) asset.resource = img asset.save end end end end //Handles saving the image class Photo < ActiveRecord::Base //..some code def original_data=(file) if file.size > 0 if file.respond_to? :read img = Magick::Image.from_blob(file.read)[0] //this call causes the error else img = Magick::Image.from_blob(file)[0] end img.format = ''JPG'' self[:original_data] = img.to_blob self.width = img.columns self.height = img.rows end GC.start end //..more code end Do I need to base 64 decode the attachment? I could find a library function to do this. -- 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 -~----------~----~----~----~------~----~------~--~---