www.SmarteGuru.com
  Home | Blogs | Recipe | Find a Friend | Discussion Board | Resources | Developers Area | Articles | Health |  Login | Register Now 

Best File Upload Plugins in Ruby on Rails

Hardly any web application this day won’t need file upload, mainly for all the media types, photos and videos. When using framework like Ruby on Rails, there are all kinds of plugins you can pick to speed up your development. For example, file upload, there are three major ones available.

These three file upload plugins are Acts As Attachment, File Column Plugin and FlexImage. The last one has nothing to do Flex, just you know. Before I start the review and comparison, I’d like say Ruby on Rails is great but documents from Ruby on Rails developers suck!

They all use RMagick to resize uploaded image and create multiple versions in different sizes.

Acts As Attachment

Written by Rick Olson, member of Ruby on Rails Core Team. It’s a very complete RoR plugin, in terms of testing and well structured code. Allows you to specify that a model accepts file uploads and stores the necessary meta info (filename, size, etc)

Good Feature:
* The generator comes with it can generate model with metadata such as file size, content type, height and width, etc. The data will be populated at creation time automatically. The data structure also trace the relationship between main image and the thumbnail image via self reference attribute parent_id, a defaulting attribute name for RoR to allow out of box Acts As Tree behavior.
* It allows you store file in file system or database blob, with reasonable default filesystem directory structure, to RAILS_ROOT/public/my_models/5/blah.jpg.

Short Comings:
* Have to read the source code to figure out how the file get stored. There is no way to configure the file storage place to be flexible. Some model method such public_filename has to be overwritten to make flexible location available.
* File attachment validation is flicky.

File Column Plugin

The oldest and most used file upload plugin. Makes handling of file uploads really easy and has a nice integration with rmagick.

Good Feature:

* There are ways to set custom file storage location. Good. You can do callback function at :store_dir option to make it fits exactly how you want the file get stored. The reason I’m asking for file storage flexibility is that once you know how to get file uploaded, uploading is trivial, however, managing files are big deal when you do expect large amount of files.
* It provides view helper to generate image url for viewing.
* Many RoR developers use it and provide feedback. Easier to find hacks or modifications.

FlexImage

Fleximage is a Rails plugin that tries to make image uploading and rendering super easy. This is relatively newer file upload plugin for RoR. It has build-in features to provide special effects on the image you present, via RMagick. It’s cool when you first see it and use it.

Good Feature:

* The build-in special image overlays. It’ll help you branding your data.
* It’s super easy to store image into BLOB column and retrieve it. Along with page caching, it could be great file management solution, if you like store file in DB.

Short Comings:

* Once file gets store, there is no metadata information. By default, your file name becomes the id.jpg. The original file name is not preserved unless you code something around this plugin, not very DRY.
* No flexible way of store file into filesystem under custom directories. All files, if use file system, will be stored in one place. It’s practically unrealistic for site deal with lots of uploads.

Which one you should go for? It’s actually a question harder than you thought.

Related Posts

Tags: , , , , , , ,


Viewed: 2,619 views

2 Responses to “Best File Upload Plugins in Ruby on Rails”

  1. Corey Martella Says:

    Paper Clip (http://github.com/thoughtbot/paperclip/tree/master) seems to require the least amount of headaches for my purposes provides most of the common functionality necessary including S3 storage and thumbnails

  2. iso Says:

    switched to paperclip after having used both AaA and file_column and can recommend it – flexible yet less pain to use

Leave a Reply

Comment moderation is enabled. Your comment may take some time to appear.

Home - About Us - Help - Terms and Conditions - Site Map - Link to Us - Resources - Contact Us
Google Rank Calculator | Suggest developer resource | Suggest Article
All rights reserved © 2007 SmarteGuru.com.