Issue
Deleting a file and replacing it with a new version while retaining the same filename does not work, as the new version would automatically get a prefix (_0
) attached to it each time a new version is uploaded (for example: filename_0.pdf
; filename_1.pdf
, etc.).
Resolution
Use the Media Entity Download module. It allows to link content to media/{media_id}/download no matter the filename.
Caveats:
- Depending upon your site architecture and number of files using this strategy, there might be a performance impact since Drupal will be bootstraped to fetch and return the unique route
- There is currently no integration with Pathauto
Cause
Drupal core doesn't currently support replacing uploaded files with the same filename.