Re: Storing images in folder or database?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I have faced this problem twice and each time I elected to put them in the
file system and then have some table that tracks filenames and associates to
an object in the database. Obviously you lose referential integrity but it
is possible to write a little program that checks that a row in the table
exists for each file name and a filename exists for each row in the table.

On one project we have 12GB of files and the database is only 500meg in
size. The management of the DB would have been more difficult if all of the
files were stored in it.

If you have a lot of files it is important to choose a good naming scheme
and directory structure. Our scripts automatically create a directory per
year per month per day of month. ie Files\2005\04\31\ In that way no one
directory becomes too large.

Backing up the data is also a breaze - xcopy.

You have to structure the transaction during the upload. If you start a
transaction, wait for the file to upload, add it to the database, add it to
the file system and then commit the transaction then you will have some long
running locks. Be careful that if the file does not upload correctly then
everything is clean up as expected.

There is some more code to write to manage the files and directories and the
database but it is a solution that works well.

I hope this helps. Feel free to contact me if you want more information (or
even code)

Dave A

"IkBenHet" <ikbenhet79@xxxxxxxxxxx> wrote in message
news:1117481202.079815.22780@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Hello,
>
> I am working on an ASP.NET based website project. Without going into
> much detail; One of the function on this website will be the
> possibility to upload images via a ASP.NET form to the webserver. These
> images can then be shown on to webpages throughout the site.
>
> What would be the best way of storing these images? Just by saving them
> in a folder on de webserver or in a database?
>
> What are the advantages and disadvantages of both working methods?
>
> Thanks.
>


.



Relevant Pages

  • Re: How to convert JPEG to binary using Java & save into database
    ... Actually shoving the data into the database has the advantage ... In that case the file system should be controlled - and people/process ... WAR file in place. ... images, etc, in a subdirectory of the upload directory. ...
    (comp.lang.java.programmer)
  • Re: Display images on a webpage
    ... I guess I am curious as to which is better, storing images in a database or using the file system and storing the file information in the database. ... I have googled it and it seems the consensus is to store files on the file system and use action files to display the images using input streams to display the images. ... When I meant reload is if upload a new .war file doesn't is overwrite the folder when I restart tomcat and if my images were in there they would be lost. ...
    (comp.lang.java.programmer)
  • Re: Treads in the new 6 core CPU from Intel
    ... Why do you think six cores are "fighting" for resources? ... implications of an asymmetric I/O bus structure on file system I/O? ... Why do you think the file I/O is not taking advantage of the File System Cache? ... What, in fact, do you mean by the phrase "database ...
    (microsoft.public.vc.mfc)
  • Re: inserting images into mysql database using matlab
    ... I would like to know how to insert images into mysql database and how to retrieve and display the inserted images. ... // declare a connection by using Connection interface Connection connection = null; ... /*declare a resultSet that works as a table resulted by execute a specified sql query. ... System.out.println("unsucessfull to upload image."); ...
    (comp.soft-sys.matlab)
  • Re: Question regarding to store file system metadata in database
    ... database based file system will be useful for archiving. ... but 300 metadata iops is not that fast. ... feature needed by file system is really a small part of database ...
    (Linux-Kernel)