views:

152

answers:

4

hi I have a File Uploader in my ASP.NET application Using C#, we can upload any type like images, documents, pdf etc.

I m storing it in the Filesystem and having only the Name of the File in DB. My doubt is can we store the entire file, images in DB. State me Which is good practice and why we need to use it.

Either file System Storage or SQL DB Storage.

+2  A: 

This is argumentative subjective, but I would say that storing files on the files system is better. That's what file systems are designed for and SQL Server 2008 has a new file type that allows you to do this automatically and even use transactions.

Darin Dimitrov
I think subjective rather than argumentative
Aiden Bell
A: 

Depends on:

  1. How big the file is, though big blobs can be handled efficiently in RDBMs
  2. Is it read or write heavy?
  3. How many concurrent requests for that resource
  4. Are you using any other caching mechanisms
  5. Do you have a SAN available, or a clustered filesystem

In short, without specifics, best practice is hard to give. Just depends on your constraints and requirements like any task.

Aiden Bell
hey Bell, i m not much familar with SQL but the file size would not be more than 1 or 2MB for a record. The Concurrent request would not be much. Give Me most common used system.
GayaMani
+3  A: 

Almost the same question was asked here. Check the answer:

http://stackoverflow.com/questions/2467774/working-with-images-in-wcf

It mostly depends on the size of your files. Here's a nice article.

To BLOB or Not To BLOB

For less than 256kb files storing in DB in VarBinary column is more efficient.

We store our files in MS SQL Server in a VarBinary column with 256kb restriction and it works fine.

Hope it helps. Good Luck!

hgulyan
hey Thanks guys
GayaMani
You're welcome. As I see, you're not used to accept answers.
hgulyan
A: 

In addition to the other answers that seems to concentrate on performance I'd also add access as another issue. If the files contains confidential data or access to the files needs to be audited, it is can sometimes be easier to manage this if the files are stored in a DB.

ho1
@ho - Yes but storing a secret path in the DB and having an intermediate script deliver the payload can give you the same 'barrier'
Aiden Bell
Not really, as you dont really have a trace whether it was changed. Then also another issue is backup / restore. easier in one place.
TomTom