How might I use file_column for incoming email attachments?

I’m writing a ‘Mailman’ model that catches emails sent to my
application (kind of like backpack, I think). The trouble is that
I’d like to save image attachments in the same was that file_column
saves them–in fact, I’d really like to use a simple assignment like
photo.image = attachment to save the image in its proper place.

However, I’m getting the following error from the ImageMagick
extension of file_column:

“Image invalid image”

(“image” is the name of the column, so that’s why it seems to be
duplicated).

Does anyone know how to leverage file_column’s fantastic simplicity
when dealing with this kind of incoming attachment?

Thanks,

Duane J.
(canadaduane)
http://blog.inquirylabs.com/

On 12/31/05, Duane J. [email protected] wrote:

http://blog.inquirylabs.com/


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

In grepping the source, the only place “invalid image” occurs is when
RMagick throws an exception. I use a modified magick_file_column.rb
that uses the command-line Imagemagick, because I’m not a fan of
RMagick, so I can’t say too much, but try breakpointing the first few
lines of the magick_file_column.rb to see what that exception is
coming from.


Kyle M.
Chief Technologist
E Factor Media // FN Interactive
[email protected]
1-866-263-3261

On Jan 2, 2006, at 10:48 AM, Kyle M. wrote:

“Image invalid image”
(canadaduane)
RMagick throws an exception. I use a modified magick_file_column.rb
that uses the command-line Imagemagick, because I’m not a fan of
RMagick, so I can’t say too much, but try breakpointing the first few
lines of the magick_file_column.rb to see what that exception is
coming from.

Thanks for looking in to this a bit, Kyle. I think my question is
more of an “I don’t quite understand how file_column automatically
handles IOString objects, why won’t it handle a TMail::Attachment
object?” I did find the error message that you pointed out, but I
was a bit surprised at the size of the plugin as a whole. Quite an
achievement! :slight_smile:

Any idea how I might trick or otherwise modify file_column in to
accepting TMail::Attachment object assignment (e.g. I’d like to do
this: User.new(:photo => attachment) where :photo is a file_column
column and attachment is a TMail::Attachment object)?

Duane J.
(canadaduane)
http://blog.inquirylabs.com/

On 1/3/06, Kyle M. [email protected] wrote:

http://lists.rubyonrails.org/mailman/listinfo/rails
Thanks for looking in to this a bit, Kyle. I think my question is

[email protected]
1-866-263-3261

Note that the solution I just proposed won’t help with the RMagick
issue, just getting a TMail::Attachment into FileColumn


Kyle M.
Chief Technologist
E Factor Media // FN Interactive
[email protected]
1-866-263-3261

On 1/2/06, Duane J. [email protected] wrote:

However, I’m getting the following error from the ImageMagick
Thanks,

more of an "I don’t quite understand how file_column automatically
Duane J.
(canadaduane)
http://blog.inquirylabs.com/


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

File_column relies on receiving a CGI-uploaded file, which is either a
File, or an IOString object, depending on filesize, which has been
extended with a few extra methods (original_filename, size,
local_path, content_type). If you pass an ordinary File,
FileColumn::FileCompat is mixed in to provide this functionality.
This happens in BaseUploadedFile.assign().

I don’t know much about TMail::Attachment, but if its similar enough
to File, you could replace the first line in
BaseUploadedFile.assign():

#old
if file.is_a? File

#new
if file.is_a?(File) || file.is_a?(TMail::Attachment)


Kyle M.
Chief Technologist
E Factor Media // FN Interactive
[email protected]
1-866-263-3261