Benefits of storing hex in DB over file

215 views Asked by At

I've been tasked with migrating an in-house application from ASP with a MSSQL backend to PHP with MySQL. The application allows users to upload and download files, searching the content therein etc...

After scoping out the current application, I've discovered that the previous developer stored the hex values of the files (whther it's a word/pdf etc...) in the DB, rather than creating a binary file on disk... in say a protected folder. I'm wondering if I should replicate this behaviour in the new application or perform a binary import.

In the new application I'm proposing to write a function that reads the file as a string (for full text searching in the database) and a field that stores the file location on disk.

What are the pros/cons of either method?

1

There are 1 answers

0
Halcyon On BEST ANSWER

Put the binary files on disk. There is no reason to keep them in the database.

What you might want to do is read the files with a document reader and index their content. Put that content in the database so you can easily search the files.