Monday, October 27, 2008

Easy Upload via URL with attachment_fu

Allowing file uploads with attachment_fu is super easy, but I've found that users sometimes want to be able to "upload" a file directly from a URL. This saves them the steps of downloading the file, finding it on their computer, uploading it into your app, etc.

I did a bit of digging around before I came across this handy trick that makes it pretty painless to add uploading via a URL to your app. I've wrapped up the code a bit and added in a few niceties that I found necessary to avoid raising exceptions unnecessarily.

The best part is that you don't need to change anything about your controller in order to get this to work. All you need is to add the uri attribute to your model and views, and you're good to go.

http://almosteffortless.com/2008/10/24/easy-upload-via-url-with-attachment_fu/

No comments: