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-storage:name]/[date:custom:Y]-[date:custom:m] was preferred but couldn't make it in time for RC1 so we've decided to simplify the patch to minimize the disruption and file instead.
We're now going with
[date:custom:Y]-[date:custom:m] only for all fields. On top of that we've decided to upload user avatars under
pictures/[date:custom:Y]-[date:custom:m] and to remove
file_directory: field/image completely from
field.field.user.user.user_picture.yml since it would be duplicating what the default is anyway.
Evaluate (and document in the issue summary) impact of showing internals like field machine names to end users whose browsers load an asset and expose the filename (and thus the path in the url)Attempt at answering this in #141
- Validate the approach is confirm the rc target requirements
- Review change record
User interface changes
Site builders now see the default tokens in the
File directory field for files/images. This can still be completely customized to suite their needs.
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.|