Store Images in DB or on Filesystem

good day all,

i am about to implement an image upload/display feature in my web app.

my options are store images in the database or store path to images in the database and store images on the file system.

considering that i am using JSC to do my development, which option would you experts out there suggest.

thank you

kroikie.

[365 byte] By [kroikiea] at [2007-11-26 16:14:45]
# 1
I'm doing this to my db. Works fine for me. I used the search facility to find out how to do it.
yossariana at 2007-7-8 22:37:38 > top of Java-index,Development Tools,Java Tools...
# 2
thank you for your response but could you be a lil more specificwhich option exactly did you choose,images in the database OR images on the filesystem with path in the database?and why?
kroikiea at 2007-7-8 22:37:38 > top of Java-index,Development Tools,Java Tools...
# 3

I've done both with a few projects that i've done. The first time I tried to use images, I stored them in a blob in a mysql database. I went through a few weeks of pain trying to get everything to work right.

For the current project I am working on, I am using images stored in my "/resources/images" folder and a path to them in the database and it works so much better and easier. There is much less of a learning curve for this type of image handling i believe. As far as performance I'm not sure if one is faster than the other. The main thing you have to watch out for with this method is to not use a "file" protocol, but an "http" protocol to display pictures or they will only be seen on the localhost. However I believe that is true for both procedures.

Dtbonea at 2007-7-8 22:37:38 > top of Java-index,Development Tools,Java Tools...
# 4
Hi There,here is the resource which helps you with storing retrieving images from DB http://developers.sun.com/prodtech/javatools/jscreator/reference/techart/2/retr ieve_binary_data.htmlHope it helpsK
kish@suna at 2007-7-8 22:37:38 > top of Java-index,Development Tools,Java Tools...
# 5

Generally, if you plan to store the images on the file system you need to guarantee unique file names.

I looked at doing this but wound up putting them into the DB because:

I didn't want to have to change file names.

I figured that as i was going to have to store the file's name, mime type and a bunch of other stuff it'd be neater and easier to just put the whole lot in the db. Also made backing up my app simpler as everything is in the DB.

yossariana at 2007-7-8 22:37:38 > top of Java-index,Development Tools,Java Tools...
# 6
i store images in resource dir and paths in db. It works fine !@Dtbone what do you mean by not use a "file" protocol, but an "http" protocol to display pictures ?where do i set this ?thanks
dElaya at 2007-7-8 22:37:38 > top of Java-index,Development Tools,Java Tools...
# 7

This is not so much a setting as it is a way of retrieving images.

Here is an example of using "file" protocol:

<img src="C:/directory/picture.gif">

This can only be viewed from your localhost machine that has the images and webapp.

Here is an example of using "http" protocol:

<img src="/ProjectName/resources/images/picture.gif">

This will allow any computer to view the images.

Dtbonea at 2007-7-8 22:37:38 > top of Java-index,Development Tools,Java Tools...
# 8
Thanks !
dElaya at 2007-7-8 22:37:38 > top of Java-index,Development Tools,Java Tools...