si-blog

Storing images

Posted May 20, 2004 in Databases.

Back in the mists of time, when I was studying Oracle's form building tool, I had a go at storing images in a database as BLOBs. Despite that, I have never used a database for storing images to be rendered on the web. I have always stored a path, and then bound that (to use Dreamweaver parlance) to a page.

At some point in the near future, I intend to include an image gallery in my hand-rolled blogging tool. I was wondering if anyone ever tried stored their images in their databases? I think it unlikely, but I am a curious type, so I thought I'd ask anyway.

Comments

  1. Gravatar

    I've done it once and saw no huge benefit in storing the images in the database vs. saving them on the file system as you described. Additionally, I recently discovered that PostgreSQL's handy pg_dumpall command doesn't dump BLOBs - you have to dump them separately using a different backup command.

    Posted by Simon Willison on May 20, 2004.

  2. Gravatar

    Indeed, it is with the exporting and importing of data that seems to be the biggest handicap. At one time, I considered it to be a good way to prevent hotlinking - but then mod_rewrite came along.

    Posted by Simon Jessey on May 20, 2004.

  3. Gravatar

    I would *never* *ever* store images in a datafield (BLOB).
    Use a data table to store id, title, comments on a picture, and then display it by echoing [img src="myimagedirectory/id.jpg"]
    It's less job for the database manager, and you use less memory / storage.

    Posted by Bruno Bord on May 20, 2004.

  4. Gravatar

    Yes. That is how I would normally do it. I am just curious if anyone has ever tried doing it the other way. Besides, the "database manager" would be me LOL.

    Posted by Simon Jessey on May 20, 2004.