Do not use the database - use the file system. I had the same problem, tried both approaches and, frankly, there were too many problems using db as a binary data store.
Instead, I have a folder containing all the downloaded files, with a database and an object that is associated with the downloaded files, but instead of just storing them βas isβ, I save them instead when the file name is the appropriate Checksum MD5 (or SHA-1) of the aforementioned file, which pretty well eliminates duplicate downloads and reduces overhead - require (); more efficient than dumping data from db.
source share