-1

I am curently developping a java/jee app in which i need to store files.I tried storing files as blob in the DB but i got a problem in size of files which must be configured in the application server so i am thinking about storing those files directly in the server disk.So i want to know what is better storing files as blob or directly in the disk.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
fbm
  • 245
  • 1
  • 5
  • 14
  • db is a bad place. disk only works if you only ever have one instance of the application running on the very same server / disk. Just store the files on a file server or in the cloud, e.g. S3 – luk2302 Mar 21 '18 at 09:01
  • @luk2302 why is db a bad place? – Jack Flamp Mar 21 '18 at 09:02
  • it will take up space on the db server, thus you will need larger machine. Also, db will be spending huge amounts in I/O while storing and retrieveing the file. There is a nice link which explains pros and conds of both approaches : https://softwareengineering.stackexchange.com/questions/150669/is-it-a-bad-practice-to-store-large-files-10-mb-in-a-database – akshaya pandey Mar 21 '18 at 09:04

2 Answers2

0

The best practice is to only store path of the files in the database and be sure to correctly handle deletions or modifications to avoid orphaned files.

Anto Livish A
  • 322
  • 4
  • 15
SystemGlitch
  • 2,150
  • 12
  • 27
0

It's a bad practice to store file in db.

But instead of that, you can store the file in server disk and map the file path in db. This will be good.

Federico klez Culloca
  • 26,308
  • 17
  • 56
  • 95
Anto Livish A
  • 322
  • 4
  • 15