I inherited a ruby site and the boss wants me to add a file upload form to one of the pages. Any suggestions? Should I store the files in a directory on the server or in the database? I prefeer the db but I do not know how to go about creating a table for the files. These are going to be large tif, jpg, etc files. I am new to all this so the baby talk is appreciated!
It's really a database question rather than a direct RoR question, but personally I'd opt for storing them in the file system rather than directly in the database. There's a few different reasons why, and I'm sure people could argue things back and forth, but I think having files easily accessible to the system at large is a good thing. For example- say you wanted to make thumbnails of all of your images. It would be pretty quick to just run some commands on a folder and convert them all that way. You could do the same if they were in the database, but I get the feeling it would take more processing time. Also, files just seem more accessible. You can just FTP to your box and pull them down directly if need be, and so on.
When I started using Rails a couple of years ago, I found Sebastian Kanthak's file_column to be the simplest way to work with uploading files. Rails has moved on a lot since then, but file_column works well for me and I even found it fairly easy to modify the underlying code (to serve files directly from a IIS FTP server). It also has some nice feature such as integration with RMagick that may well suit your image file handling requirements.
file_column stores the files in the applications public folder, and paths to those files in the database.
Bookmarks