I have a PHP application that uploads and stores files (think Imgur). The way it works now is all files go into one main /storage
directory. This is all fine and good, unless of course you want to do something inside that directory, a simple ls
usually crashes my terminal. This hasn't been an issue yet other than rsync taking a while to build a file list, but I want to plan for the future.
Would it be smarter to store uploads in a /year/month/file.ext
directory or is using a single directory scalable going forward? One problem with this would be that there are already millions of links out there that link directly to site.com/storage/file.ext
which would need to be redirected to the new location - what is the proper way of doing this without hammering mysql every time an image is requested?