Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

Rails File Uploading 101

By Peter Cooper / March 2, 2007

Murderers
Mike Clark has put together a stunningly simple tutorial covering how to create a complete file uploading and image resizing system in mere minutes using Rick Olson's attachment_fu plugin. What impresses me the most is that he shows how attachment_fu can automatically store uploaded files on Amazon's S3 service with only a few tweaks. This is a must read for Rails developers who haven't brushed up on their file upload techniques lately.

Comments

  1. Isaac says:

    I posted a quick response to Mike's tutorial here:

    http://isaac.org.nz/2007/2/25/image-processing-with-attachment_fu

    It outlines why I ended up going with mini_magick as an image processor.

  2. Jeff Coleman says:

    One thing Mike didn't mention is that there seem to be issues using attachment_fu with Windows:
    http://railsweenie.com/forums/3/topics/1257

    It seems to have trouble saving the correct size of the files. Acts_as_attachment seems to work correctly, but something's up in attachment_fu.

  3. Wes Ratcliff says:

    I'll second the problem on Windows... haven't found a fix yet.

  4. Jon Maddox says:

    Ahh, this is very nice indeed. Little has been documented about this plugin. Rick hadn't even written much in the README yet.

    This rocks.

  5. Jeff de Vries says:

    Neat! I added photo upload to our site using these instructions (modified for our models) in under an hour, and it worked the first time!

  6. Don says:

    All of the file upload examples that I've found seem to be geared toward image uploads. How well does something like attachment_fu work for non-image uploads? Is there something better for handling arbitrary file types?

  7. Peter Cooper says:

    Should be fine, Don. Most upload plugins are for arbitrary files, it's just that because image uploads are so popular.. they provide short cuts and useful methods for that.

  8. Don says:

    If I set attachment_fu to store uploaded files in the file system, it puts them in the 'public' directory of the Rails app. I can specify a path for uploads, but it's relative to 'public'. My app is going to be deployed on a multi-user system, so I need to store files in a path relative to ~username. Is there a plug-in that allows that?

Other Posts to Enjoy

Twitter Mentions