This does not really answer your question, but I thought I would share it anyway ...
There are two ways to store files using the database: in fact: saving the actual contents of the file (like you) and saving only the path to the file (and saving it to the actual file system).
I worked with both methods, and I preferred the latter for two reasons: I can move files to other hard drives, partitions, and even access them through a shared resource, and all I need to do is change the file paths to the databases . In addition, it makes database dumps (aka backups) much smaller and faster to execute.
Andre source share