在ASP.NET中,最好将上传的文件存储到关系数据库中,还是将其放入文件系统中?

时间:2022-10-03 16:36:56

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?

将上传的文件存储到关系数据库中或将其放在IIS中的目录下的文件系统中是否很好?我认为关系系统将是一个更好的选择。任何意见?你什么时候用一个而不是另一个?

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

编辑:RDBMS,可以更容易地将多个文件附件与记录相关联。维护版本更容易

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

文件系统可以更容易地存储数据,我认为性能明智,这是一个更好的选择。

1 个解决方案

#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!

当您在Web场中时,首选将文件存储在数据库中 - 例如,如果您的应用程序的请求由多个服务器处理并且您将文件存储在数据库中,那么您只需要SQL集群,并将文件存储在在这种情况下,文件系统要困难得多 - 您必须使用公共位置或通过服务器场同步文件!

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

这篇文章解释了如何在数据库中存储: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

以下是有关SQL Server 2008和文件流功能的有趣读物:http://www.devx.com/dotnet/Article/40812

#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!

当您在Web场中时,首选将文件存储在数据库中 - 例如,如果您的应用程序的请求由多个服务器处理并且您将文件存储在数据库中,那么您只需要SQL集群,并将文件存储在在这种情况下,文件系统要困难得多 - 您必须使用公共位置或通过服务器场同步文件!

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

这篇文章解释了如何在数据库中存储: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

以下是有关SQL Server 2008和文件流功能的有趣读物:http://www.devx.com/dotnet/Article/40812