[英]When should i upload a file into a database instead of the server in a web application?
As the title says, i am concerned about when i should upload a file on a database rather than the server. 如标题所示,我担心何时应该在数据库而不是服务器上上传文件。
In these days i first encountered the necessity of uploading .pdf files into my web application in order to make it accessible for everyone who needs it. 这些天来,我首先遇到了将.pdf文件上传到我的Web应用程序中的必要性,以使需要它的每个人都可以使用它。 But my first approach at it was uploading a file into a database.
但是我的第一个方法是将文件上传到数据库中。
But that wasn't my case; 但这不是我的情况。 i just needed to upload a file and, with a download link, make it downloadable from the user.
我只需要上传文件,并带有下载链接,就可以从用户那里下载文件。
But on the other side, i wondered, since the big limitations of "blob" type: when should i upload a file into a database rather then the server? 但另一方面,我想知道“ blob”类型的局限性:我什么时候应该将文件上传到数据库而不是服务器?
I have always preferred to store items on the filesystem and store the paths in the database . 我一直希望将项目存储在文件系统中 ,并将路径存储在数据库中 。
I think the only advantage to putting it in a BLOB is that you can move the database around and not have to worry about distributing files. 我认为将其放入BLOB的唯一好处是您可以移动数据库,而不必担心分发文件。 For normal websites this wouldn't really matter but for some kind of product like a CMS or website addon it would be a handy way to include a resource file with the distribution...
对于普通网站来说,这并不重要,但是对于CMS或网站插件之类的产品而言,将资源文件包含在发行版中将是一种便捷的方式...
The reason I prefer the filesystem is because that is what the filesystem is designed for - serving files. 我之所以喜欢文件系统,是因为文件系统是为服务文件而设计的。 I don't see any valid reason to put all that stress into a bottleneck by pushing all the data through the database.
我看不出有任何正当理由通过将所有数据推入数据库而使所有压力成为瓶颈。
On the other hand the only time I reccomend storing files as a BLOB in SQL is when the images or files contain sensitive data (ie Medical Images, etc.) where you need the security that SQL Server provides. 另一方面,我唯一建议在SQL中将文件存储为BLOB的情况是,当图像或文件包含敏感数据(例如,医学图像等)时,您需要SQL Server提供的安全性。 Otherwise storing and reading the file from a filesystem is much faster;
否则,从文件系统存储和读取文件会更快。 you can keep a reference to the file's location in SQL Server for the best method.
您可以保留对SQL Server中文件位置的引用,以获取最佳方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.