Pro & Cons of storing files(pictures) in a SQL Server for a website

后端 未结 3 1764
时光取名叫无心
时光取名叫无心 2021-01-23 02:54

I\'m creating an Asp.Net MVC website.

I\'ve in the past, for heavy application, multiple layer application, used the database to store files.

But now I\'m questi

3条回答
  •  猫巷女王i
    2021-01-23 03:25

    Why use db instead of txt files? Because its faster it uses indexes. Storing whole files in db is never a good practice. Use db as index (pointers) to the normal img files.

    As far as your pros / cons go:

    • you can easily controll if the user has the right to see the image if you display the image with asp / php and set root image folder outside web root

    • storing whole files in db is cca 10 times slower (I know for mysql testing but its similar for mssql - http://blog.sitek.com.au/2008/03/comparison-between-storing-imagesfiles-in-mysql-and-on-filesystem/)

    • if you have files in db you wont be able to use CDNs (http://en.wikipedia.org/wiki/Content_delivery_network)

提交回复
热议问题