This week I have been mostly discovering what a wonderful Rails plugin attachment_fu is for handling image uploads. You just hand it the contents of an upload field on a form, and it takes care of everything else – checking that it’s a valid image, working out its file type, choosing a sensible filename for it, resizing it appropriately, and sticking the resulting image file into either the filesystem, the database, or Amazon S3.
That last feature has been particularly handy on Demozoo, which is currently hosted in borrowed space on a server that doesn’t really have 100-odd megabytes of free space for demo screenshots. However, attachment_fu comes a bit unstuck when you’re dealing with files that don’t come from a form upload – for instance, in my case I’m planning to have a scheduled task that leeches new productions and their screenshots from Pouët, and I’d quite like to take advantage of the Imagemagick-and-S3 goodness that attachment_fu brings. A bit of digging around was in order.