Reputation: 1060
I am working on an application that will allow me to upload pdf files and then display them when a user clicks on it, much like this website http://www.rangairemfg.com/products
I cant decide if I would store the pdfs in the database, or if I should store them on the filesystem and link them through the database.
I know that paperclip would be a good way of doing the second option. Does anyone have any suggestions or a better way of doing this?
Upvotes: 0
Views: 964
Reputation: 14959
The Paperclip option is better. You can store a file in a database as a blob field if you really want to, but it adds little value and will clog up the DB connection due to the volume of data being transferred. Use the database for the purpose it is designed for: joining tables of information together and getting extremely fast results so you can load pages quickly. Unless you don't care about slowing your DB down, you should use a file system for storing files.
Paperclip integrates nicely with S3, which is both cheap and reliable. That way, your user can click a link and have a new page open with the direct url of the S3 file (exactly the same as the site you link to) and the rest of your site is completely unaffected. The idea is that Paperclip stores only the file url in the database, which is returned super-fast, then the user connects directly to S3 for the slow bit.
Upvotes: 1