Drupal will upload files into one directory by default. Users can affect this by changing configuration of file/image fields, but real-world experience shows that they don't. Uploading thousands or millions of files into one directory is a very bad idea, which can have performance implications too. There are reports of sites going down just as a result of this issue.
Let's change default location configuration variable in file/image fields. This variable is currently empty, which results in all files being uploaded in a root folder (usually public://). Since use of tokens is supported we can provide configuration that will dynamically adapt for different fields.
"field/[field-storage:name]/[date:custom:Y]/[date:custom:m]" is suggested.
- review patch
- review change record
User interface changes
Original issue summary by @meba
It is a well known fact that if you upload thousands of files into a single directory you will have performance issues on certain systems such as Cloud systems using GlusterFS, NFS or other shared filesystems or simply slow hard drives. The reason being that list operations on that single directory take too much overhead over network.
The solution typically is to ensure there is no more than a couple of thousands of files in a single directory in your files/. This can be easily achieved through dividing directories by date:
https://drupal.org/project/filefield_paths provides this functionality but many people do not install it when they create their website and migration is complicated.
I propose that we automatically add date based tokens to all file system paths in Drupal core and allow modules such as FileField Paths to override these tokens to provide advanced functionality.
Beta phase evaluation
|Issue category||Task because it's not really new functionality, but it's not really a bug as nothing is broken.|
|Issue priority||Normal because it's not a blocker for anything.|
|Prioritized changes||The main goal of this issue is usability.|
|Disruption||This issue should have no disruption for any existing APIs, modules, or sites.|
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 90,551 pass(es).
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 90,098 pass(es).
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 90,153 pass(es).