storing uploaded photos and documents - filesystem vs database blob

前端 未结 6 2093
鱼传尺愫
鱼传尺愫 2020-12-06 06:31

My specific situation

Property management web site where users can upload photos and lease documents. For every apartment unit, there might be 4 ph

6条回答
  •  误落风尘
    2020-12-06 06:57

    File system. No contest. The data has to go through a lot more layers when you store it in the db.

    Edit on caching: If you want to cache the file while the user uploads it to ensure the operation finishes as soon as possible, dumping it straight to disk (i.e. file system) is about as quick as it gets. As long as the files aren't too big and you don't have too many concurrent users, you can 'cache' the file in memory, return to the user, then save to disk. To be honest, I wouldn't bother.

    If you are making the files available on the web after they have been uploaded and want to cache to improve the performance, file system is still the best option. You'll get caching for free (may have to adjust a setting or two) from your web server. You wont get this if the files are in the database.

    After all that it sounds like you should never store files in the database. Not the case, you just need a good reason to do so.

提交回复
热议问题