简体   繁体   English

什么时候应该将文件上传到数据库而不是Web应用程序中的服务器?

[英]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.

相关问题 我应该将PHPMyAdmin上传到服务器吗 - Should I upload PHPMyAdmin to the server 无法将文件上传到Web服务器 - Not able to upload file to web server 通过Web服务器使用PHP代码将应用程序中的本地文件上传到FTP服务器 - Upload a local file from application via web server with PHP code to FTP server 将图像上传到Web服务器并将路径存储在数据库中 - Upload image to web server and store path in database 当我尝试将文件上传到我的网络服务器时,它不起作用,但如果将它们上传到本地,它就起作用了 - When i try to upload files to my web server it doesnt work but if upload them locally it works 如何编辑表单和脚本以将两个文件而不是一个文件上传到服务器,将文件名上传到mysql - How do I edit form and script to upload two files instead of one -file to server, file name to mysql iOS到php服务器的文件上传-我应该允许什么文件大小的图像? - iOS to php server file upload - what file size image should I allow? 我应该在当前文件中添加文件上传大小而不在服务器上添加php.ini和htaccess吗 - Should i add file upload size in current file without adding php.ini & htaccess on server Web应用程序中的文件上传和存储处理 - File upload and storage handling in a web application 以API为中心的Web应用程序文件上传 - API-centric web application file upload
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM