Duane Johnson
2005-Dec-31 22:26 UTC
[Rails] 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 Johnson (canadaduane) http://blog.inquirylabs.com/
Kyle Maxwell
2006-Jan-02 17:48 UTC
[Rails] How might I use file_column for incoming email attachments?
On 12/31/05, Duane Johnson <duane.johnson@gmail.com> wrote:> 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 Johnson > (canadaduane) > http://blog.inquirylabs.com/ > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > 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 Maxwell Chief Technologist E Factor Media // FN Interactive kyle@efactormedia.com 1-866-263-3261
Duane Johnson
2006-Jan-03 03:46 UTC
[Rails] How might I use file_column for incoming email attachments?
On Jan 2, 2006, at 10:48 AM, Kyle Maxwell wrote:> On 12/31/05, Duane Johnson <duane.johnson@gmail.com> wrote: >> 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 Johnson >> (canadaduane) >> http://blog.inquirylabs.com/ >> >> >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> 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.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! :) 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 Johnson (canadaduane) http://blog.inquirylabs.com/
Kyle Maxwell
2006-Jan-03 18:01 UTC
[Rails] How might I use file_column for incoming email attachments?
On 1/2/06, Duane Johnson <duane.johnson@gmail.com> wrote:> > On Jan 2, 2006, at 10:48 AM, Kyle Maxwell wrote: > > > On 12/31/05, Duane Johnson <duane.johnson@gmail.com> wrote: > >> 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 Johnson > >> (canadaduane) > >> http://blog.inquirylabs.com/ > >> > >> > >> _______________________________________________ > >> Rails mailing list > >> Rails@lists.rubyonrails.org > >> 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. > > > 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! :) > > 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 Johnson > (canadaduane) > http://blog.inquirylabs.com/ > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > 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 Maxwell Chief Technologist E Factor Media // FN Interactive kyle@efactormedia.com 1-866-263-3261
Kyle Maxwell
2006-Jan-03 18:02 UTC
[Rails] How might I use file_column for incoming email attachments?
On 1/3/06, Kyle Maxwell <kyle@kylemaxwell.com> wrote:> On 1/2/06, Duane Johnson <duane.johnson@gmail.com> wrote: > > > > On Jan 2, 2006, at 10:48 AM, Kyle Maxwell wrote: > > > > > On 12/31/05, Duane Johnson <duane.johnson@gmail.com> wrote: > > >> 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 Johnson > > >> (canadaduane) > > >> http://blog.inquirylabs.com/ > > >> > > >> > > >> _______________________________________________ > > >> Rails mailing list > > >> Rails@lists.rubyonrails.org > > >> 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. > > > > > > 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! :) > > > > 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 Johnson > > (canadaduane) > > http://blog.inquirylabs.com/ > > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > 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 Maxwell > Chief Technologist > E Factor Media // FN Interactive > kyle@efactormedia.com > 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 Maxwell Chief Technologist E Factor Media // FN Interactive kyle@efactormedia.com 1-866-263-3261