In ASP.NET is it better to store an uploaded file into a relational database, or put it into the file system?

Is it good to store the uploaded file into a relational database or put it in a file system under a directory in IIS? I thought relational system will be a better choice. Any comments? When will you use one over the other?

EDIT: RDBMS, will make it easier to relate multiple file attachments to a record. It’s easier to maintain version(s)

File systems make it easier to store data and I think performance wise this is a better choice.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

It really depends on the case. If you are storing very large files your DB will become really big – consider this – it may affect the price of your hosting.

Storing files in a DB is preferred when you are in a web farm – for example if the requests to your application are processed by several servers and you store the files in a DB, then SQL clustering is all you need, and storing the files in the file system in such case is a lot harder – you have to use a common location or synchronize the files through the server farm!

I would use a DB for a file store – one location for all the data related to your application – easier to maintain and backup/restore!

Here is an article explaining how to store in a DB: http://www.dbazine.com/sql/sql-articles/charran5

Here is an interesting reading about SQL Server 2008 and the filestream feature: http://www.devx.com/dotnet/Article/40812


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x