Topic: Retrieve images from Database

How to retrieve images (stored in BLOB format, seperate image for each user) from the database?

Thanks,
Suhas

Last edited by suhaspnehete (2006-10-26 09:34:06)

Re: Retrieve images from Database

How are the images stored? As BLOB (Binary Large OBject) data, or as a reference to where it would be found on the filesystem?

vinnie - rails forum admin

Re: Retrieve images from Database

Well, since I'm thinking of the same thing, I might as well hijack this old post...

I want users to be able to upload pictures (avatars and such).  Is it better to store these in the database or the file system?  I like using the database because it keeps everything together, but I don't know how to serve images from a database, or if that's even wise.

What are other people doing?  What are the pros/cons of the different approaches.

Note: To answer the previous question, I was planning on storing the JPEG data as a BLOB in the database.  Obviously, the other route is to store a file path to the image.

If there is a post/website/blog entry/whatever that answers my questions, please don't hesitate to simply post a link.  I know it can get old fast to answer the same question hundreds of times...

Re: Retrieve images from Database

See this sitepoint article for some reasons you may want to store images in the database. Make sure to read the comments too for counter-reasons.

I prefer to store them in the filesystem.

Railscasts - Free Ruby on Rails Screencasts