Hi there, here is the announcement from http://www.kanthak.net/explorations/blog/rails/file_column_0.3.html Here is the new 0.3 release of the file_column library that makes handling of file uploads in rails really easy. So what''s new? The most prominent new feature is an integration of rmagick/imagemagick so that you can easily resize uploaded images and create multiple versions in different sizes. Many thanks to Kyle Maxwell for his ideas on this subject. You certainly ask yourself how this works? It''s very straightforward, as always. Let me just show you an example: class Entry file_column :image, :magick => { :geometry => "640x400>" } end Just grab the release and look at the docs for more details. As an additional goodie, I converted file_column to a rails plugin, so you can just drop it into your "vendor/plugins" directory and you''re done. This plugin thingie is certainly a cool new feature in rails. For all of you, interested in all the details: Here''s a list of all the changes since the last version straight from the changelog: * fixed bug where empty file uploads were not recognized with some browsers * fixed bug on windows when "file" utility is not present * added option to disable automatic file extension correction * Only allow one attribute per call to file_column, so that options only apply to one argument * try to detect when people forget to set the form encoding to ''multipart/form-data'' * converted to rails plugin * easy integration with RMagick As always, feedback and suggestions are very welcome. Sebastian
Nice.. THANKS! I love this community. On 10/28/05, Sebastian Kanthak <skanthak-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi there, > > here is the announcement from > http://www.kanthak.net/explorations/blog/rails/file_column_0.3.html > > Here is the new 0.3 release of the file_column library that makes > handling of file uploads in rails really easy. > > So what''s new? The most prominent new feature is an integration of > rmagick/imagemagick so that you can easily resize uploaded images and > create multiple versions in different sizes. Many thanks to Kyle > Maxwell for his ideas on this subject. > > You certainly ask yourself how this works? It''s very straightforward, > as always. Let me just show you an example: > > class Entry > file_column :image, :magick => { :geometry => "640x400>" } > end > > Just grab the release and look at the docs for more details. > > As an additional goodie, I converted file_column to a rails plugin, so > you can just drop it into your "vendor/plugins" directory and you''re > done. This plugin thingie is certainly a cool new feature in rails. > > For all of you, interested in all the details: Here''s a list of all > the changes since the last version straight from the changelog: > > * fixed bug where empty file uploads were not recognized with some browsers > * fixed bug on windows when "file" utility is not present > * added option to disable automatic file extension correction > * Only allow one attribute per call to file_column, so that > options only apply to one argument > * try to detect when people forget to set the form encoding to > ''multipart/form-data'' > * converted to rails plugin > * easy integration with RMagick > > As always, feedback and suggestions are very welcome. > > Sebastian > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- - Ramin http://www.getintothis.com/blog
can´t thank you enough sebastian :) I´ve a few projects using (depending on) it already. 2005/10/28, Ramin <i8ramin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> Nice.. THANKS! I love this community. > > On 10/28/05, Sebastian Kanthak <skanthak-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi there, > > > > here is the announcement from > > http://www.kanthak.net/explorations/blog/rails/file_column_0.3.html > > > > Here is the new 0.3 release of the file_column library that makes > > handling of file uploads in rails really easy. > > > > So what''s new? The most prominent new feature is an integration of > > rmagick/imagemagick so that you can easily resize uploaded images and > > create multiple versions in different sizes. Many thanks to Kyle > > Maxwell for his ideas on this subject. > > > > You certainly ask yourself how this works? It''s very straightforward, > > as always. Let me just show you an example: > > > > class Entry > > file_column :image, :magick => { :geometry => "640x400>" } > > end > > > > Just grab the release and look at the docs for more details. > > > > As an additional goodie, I converted file_column to a rails plugin, so > > you can just drop it into your "vendor/plugins" directory and you''re > > done. This plugin thingie is certainly a cool new feature in rails. > > > > For all of you, interested in all the details: Here''s a list of all > > the changes since the last version straight from the changelog: > > > > * fixed bug where empty file uploads were not recognized with some browsers > > * fixed bug on windows when "file" utility is not present > > * added option to disable automatic file extension correction > > * Only allow one attribute per call to file_column, so that > > options only apply to one argument > > * try to detect when people forget to set the form encoding to > > ''multipart/form-data'' > > * converted to rails plugin > > * easy integration with RMagick > > > > As always, feedback and suggestions are very welcome. > > > > Sebastian > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > -- > - Ramin > http://www.getintothis.com/blog > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
one suggestion, by the way... do you think it´d make sense to allow for multiple file_columns for a single model? as an example, I have a page model that uses file_column for a single image in it. But, i´d like to extend this model for a homepage model, and allow for 3 images on it, without needing to use an external model for them, like I do now whenever I have multiple images for a page, making up galleries. is it complicated to do? i feel like a spoiled kid asking for more and more ;)
Francois Beausoleil
2005-Oct-29 14:53 UTC
Re: [ANN] file_column_0.3 plugin with rmagick support
Hi ! 2005/10/29, Oliver Barnes <ol1barn3s@gmail.com>:> one suggestion, by the way... > do you think it´d make sense to allow for multiple file_columns for a > single model?Isn't that already possible: class Entry file_column :small, :magick => {:geometry => '80x60'} file_column :thumb, :magick => {:geometry => '160x120'} file_column :original end Bye ! François _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Sebastian Kanthak
2005-Oct-29 15:46 UTC
Re: [ANN] file_column_0.3 plugin with rmagick support
On 10/29/05, Oliver Barnes <ol1barn3s-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> one suggestion, by the way... > do you think it´d make sense to allow for multiple file_columns for a > single model?as Francois suggests, you can call file_column multiple times like this: class Entry file_column :wife, :magick => { :geometry => "640x480>" } file_column :kids, :magick => { :geometry => "640x480>" } end In this case, you need two columns for holding the filenames as well. Francois, if you just want to keep one image in different sizes, you can use the "versions"-feature: class Entry file :image, :magick => { :geometry => "1280x1024>", :versions => { "big" => "1024x768>", "medium" => "640x480>", "thumb" => "50x50" } } end You can access these different sizes via entry.image("medium") or in your view with <%= url_for_file_column "entry", "image", "medium" %> Hope this helps Sebastian
David Heinemeier Hansson
2005-Oct-29 16:39 UTC
Re: [ANN] file_column_0.3 plugin with rmagick support
> Here is the new 0.3 release of the file_column library that makes > handling of file uploads in rails really easy.This is fabulous stuff, Sebastion. Great example of a plugin. Would you by any chance have the opportunity to put this plugin on a public Subversion repository? SVN is the new baseline for distributing plugins (see script/plugin in beta gems). That would top it off. -- David Heinemeier Hansson http://www.loudthinking.com -- Broadcasting Brain http://www.basecamphq.com -- Online project management http://www.backpackit.com -- Personal information manager http://www.rubyonrails.com -- Web-application framework
Sebastian Kanthak
2005-Oct-29 17:36 UTC
Re: [ANN] file_column_0.3 plugin with rmagick support
On 10/29/05, David Heinemeier Hansson <david.heinemeier-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Here is the new 0.3 release of the file_column library that makes > > handling of file uploads in rails really easy. > > This is fabulous stuff, Sebastion. Great example of a plugin. Would > you by any chance have the opportunity to put this plugin on a public > Subversion repository? SVN is the new baseline for distributing > plugins (see script/plugin in beta gems). That would top it off.thanks for the praise, David :) I''d love to make it accessible via svn. Unfortunately, I cannot setup a svn server myself. I already looked at rubyforge but it seems they only support CVS and I don''t want to use this anymore, really :) So, can anybody sponsor a svn server for file_column? Sebastian
dmarko-KxaEA3z1jV+iEHBPiYQIQwC/G2K4zDHf@public.gmane.org
2005-Oct-29 18:40 UTC
Re: [ANN] file_column_0.3 plugin with rmagick support
> Here is the new 0.3 release of the file_column library that makes > handling of file uploads in rails really easy.Does anyone know how to make uploaded files safe? It seems now that all pictures are available for all web users as they are stored in public directory. Is there any way how to protect each picture to be available only for certatin user (user that uploaded the file)? Thanks for your experience, David Marko _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Hunter Hillegas
2005-Oct-29 18:53 UTC
Re: [ANN] file_column_0.3 plugin with rmagick support
We use Rails send_file¹ method to handle this. True, users could still get to the files if they knew the path... If that bothers you, you should be able to hack file_column to store them outside of the Web root and then use that in conjunction with send_file¹. From: <dmarko-KxaEA3z1jV+iEHBPiYQIQwC/G2K4zDHf@public.gmane.org> Reply-To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> Date: Sat, 29 Oct 2005 20:40:30 +0200 To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> Subject: Re: [Rails] [ANN] file_column_0.3 plugin with rmagick support> Here is the new 0.3 release of the file_column library that makes > handling of file uploads in rails really easy.Does anyone know how to make uploaded files safe? It seems now that all pictures are available for all web users as they are stored in public directory. Is there any way how to protect each picture to be available only for certatin user (user that uploaded the file)? Thanks for your experience, David Marko _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Sebastian Kanthak
2005-Oct-29 21:13 UTC
Re: [ANN] file_column_0.3 plugin with rmagick support
On 10/29/05, Hunter Hillegas <lists-HAWAbpnI61OZ1JSuHaJ1sQC/G2K4zDHf@public.gmane.org> wrote:> We use Rails ''send_file'' method to handle this. True, users could still get > to the files if they knew the path... If that bothers you, you should be > able to hack file_column to store them outside of the Web root and then use > that in conjunction with ''send_file''.Yipp, that works. Just to clarify: You serve the files via a controller (instead of directly through the webserver), so that you can control access in your controller. As Hunter suggested, you can change the path file_column uses to store the files via the :root_path configuration option. If you set the :base_url option as well, you can even use url_for_file_column as before: class Entry file_column :image, :root_path => "#{RAILS_ROOT}/protected", :base_url => "secret_image_controller" end Now, file will be stored in ".../protected/entry/image" and when use url_for_file_column, URLs of the form ".../secret_image_controller/42/vacation.jpg" will be generated. And yes, I know that I have to document these configuration options better :) Sebastian
doh, don''t know why I just assumed it was only possible for a single column! thanks! 2005/10/29, Sebastian Kanthak <skanthak-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> On 10/29/05, Oliver Barnes <ol1barn3s-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > one suggestion, by the way... > > do you think it´d make sense to allow for multiple file_columns for a > > single model? > > as Francois suggests, you can call file_column multiple times like this: > > class Entry > file_column :wife, :magick => { :geometry => "640x480>" } > file_column :kids, :magick => { :geometry => "640x480>" } > end > > In this case, you need two columns for holding the filenames as well. > > Francois, if you just want to keep one image in different sizes, you > can use the "versions"-feature: > > class Entry > file :image, :magick => { :geometry => "1280x1024>", > :versions => { > "big" => "1024x768>", > "medium" => "640x480>", > "thumb" => "50x50" } > } > end > > You can access these different sizes via entry.image("medium") or in > your view with <%= url_for_file_column "entry", "image", "medium" %> > > Hope this helps > Sebastian > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Francois Beausoleil
2005-Oct-30 14:43 UTC
Re: [ANN] file_column_0.3 plugin with rmagick support
Hi, 2005/10/29, Sebastian Kanthak <skanthak@gmail.com>:> I'd love to make it accessible via svn. Unfortunately, I cannot setup > a svn server myself. I already looked at rubyforge but it seems they > only support CVS and I don't want to use this anymore, really :) > > So, can anybody sponsor a svn server for file_column?No need, just look at http://opensvn.csie.org/ Bye !, François _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Robert Williams
2005-Oct-30 23:32 UTC
Re: [ANN] file_column_0.3 plugin with rmagick support
Hello Everyone, I''ve created a model: (so what??) class Image < ActiveRecord::Base file_column :file, :root_path => "#{RAILS_ROOT}/public/upload", :magick => { :geometry => "1024x768>", :versions => { "thumb" => "75x75" } } end It uploads fine and creates those two files. But when i call "url_for_file_column(''file'', ''image'') it fails with a nil object error. Has anybody got any ideas? Rob.
Bogdan Ionescu
2005-Oct-30 23:41 UTC
Re: [ANN] file_column_0.3 plugin with rmagick support
It should be url_for_file_column(''image'',''file'') or url_for_file_column(''image'',''file'',''thumb'') Obviously image would be an object of type Image. bogdan On 10/31/05, Robert Williams <booshank-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hello Everyone, > > I''ve created a model: (so what??) > > class Image < ActiveRecord::Base > file_column :file, :root_path => "#{RAILS_ROOT}/public/upload", > :magick => { > :geometry => "1024x768>", > :versions => { "thumb" => "75x75" } > } > end > > It uploads fine and creates those two files. But when i call > "url_for_file_column(''file'', ''image'') it fails with a nil object > error. Has anybody got any ideas? > > Rob. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
I''m currently working on getting up a SVN repository for this project. Should be up midweek. Kyle On 10/30/05, Bogdan Ionescu <bogdan.ionescu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> It should be url_for_file_column(''image'',''file'') or > url_for_file_column(''image'',''file'',''thumb'') > Obviously image would be an object of type Image. > bogdan > > > On 10/31/05, Robert Williams <booshank-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hello Everyone, > > > > I''ve created a model: (so what??) > > > > class Image < ActiveRecord::Base > > file_column :file, :root_path => "#{RAILS_ROOT}/public/upload", > > :magick => { > > :geometry => "1024x768>", > > :versions => { "thumb" => "75x75" } > > } > > end > > > > It uploads fine and creates those two files. But when i call > > "url_for_file_column(''file'', ''image'') it fails with a nil object > > error. Has anybody got any ideas? > > > > Rob. > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Hi This looks great.. I especially like the integration with RMagik. I just have one quick question. Is it possible to specify a height only (or width) and keep the original H x W ratio? That way ppl could upload any sized image and the resize operation would not distort the image. Just a thought... Cheers Dan On 10/31/05, Kyle Maxwell <kyle-FOSOgQihYpQjo0HpFSRKWA@public.gmane.org> wrote:> > I''m currently working on getting up a SVN repository for this project. > Should be up midweek. > > Kyle > > On 10/30/05, Bogdan Ionescu <bogdan.ionescu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > It should be url_for_file_column(''image'',''file'') or > > url_for_file_column(''image'',''file'',''thumb'') > > Obviously image would be an object of type Image. > > bogdan > > > > > > On 10/31/05, Robert Williams <booshank-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hello Everyone, > > > > > > I''ve created a model: (so what??) > > > > > > class Image < ActiveRecord::Base > > > file_column :file, :root_path => "#{RAILS_ROOT}/public/upload", > > > :magick => { > > > :geometry => "1024x768>", > > > :versions => { "thumb" => "75x75" } > > > } > > > end > > > > > > It uploads fine and creates those two files. But when i call > > > "url_for_file_column(''file'', ''image'') it fails with a nil object > > > error. Has anybody got any ideas? > > > > > > Rob. > > > _______________________________________________ > > > Rails mailing list > > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Sebastian Kanthak
2005-Nov-02 12:59 UTC
Re: [ANN] file_column_0.3 plugin with rmagick support
On 11/2/05, Liquid <has.sox-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I just have one quick question. Is it possible to specify a height only (or > width) and keep the original H x W ratio? That way ppl could upload any > sized image and the resize operation would not distort the image.it just accepts standard imagemagick geometry strings. I''m certain that they have this feature. It''s something like "x100" I think, but you have to look up the exact syntax in the (r)magick docs yourself. Sebastian
On Wed, Nov 02, 2005 at 01:59:55PM +0100, Sebastian Kanthak wrote:> On 11/2/05, Liquid <has.sox-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I just have one quick question. Is it possible to specify a height only (or > > width) and keep the original H x W ratio? That way ppl could upload any > > sized image and the resize operation would not distort the image.If you specify a geometry string with a > it will limit the size properly scaled to those dimentions. So 300x300> says resize the height to a max of 300 and the width to a max of 300 but do not scale if either are less than that. So it picks the highest one and scales proportiatly until the highest dimention is within the box. -- Owen _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails