Rails File Uploading 101

In Cool, Elsewhere, Ruby on Rails, Tutorials

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.

Vaguely Related Posts (Usually)

8 Comment Responses to “Rails File Uploading 101”

  1. #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. #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. #3
    Wes Ratcliff Says:

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

  4. #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. #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. #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. #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. #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?