Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving PDF files in DB or File-System

In my website project, I need to upload the end-user's pdf files and save them. every 3 months I guess to receive around 2000 pdf files with 2MB size for each pdf. What is the best solution? saving the files in hard-disk (in a folder) and save file-address in the DB < or > saving the files directly in a blob-field in the db(MySQL)

RGDS

like image 542
Nav Avatar asked Jan 21 '23 01:01

Nav


1 Answers

Saving large amounts of binary data as BLOBs is not a good idea because the benefits over using a regular file system are minimal and the load on the DBMS is increased. Storing a file on the disk and file's name in the DB is a better idea.

One thing to remember is to avoid putting all files into single directory (doing this will slow down the file system when the files are accessed). Put them into subdirectories and use first couple of characters of the file name as the name of the subdirectory.

like image 180
Eugene Mayevski 'Callback Avatar answered Jan 30 '23 13:01

Eugene Mayevski 'Callback