[3.x] Allow "deduplication" on media and file libraries #899
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Related to #880
This PR introduces some changes:
Allow media and files to be "deduplicated" by using the SHA1 hash of files contents to generate directory or file names:
Allow users to enable deduplication and choose if it will keep the current structure (file inside a hashed directory) or flatten it and just use the
<sha1 hash>.extension
as the filename:I feel this is can be a problem if people wants to download their files using the file original file name, but it also fixes another problem: sometimes the filename used by the user is incompatible (has special chars, accents) with the file system used to store that file. About the download part, it can be fixed in the CMS by using the original filename (stored on the medias table) to download it instead of the UUID.
Fix a potential bug on frontend passing
undefined
and"null"
values to the backend, generating this kind of errors while adding an image:Refactor
MediaLibraryController.php
andFileLibraryController.php
to DRY them a bit by introducing a newLibraryController.php
abstract base class containing common code.