简体   繁体   中英

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. 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?

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. 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...

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM