Allow to rewrite filename with a custom name when it's download

Created on 28 September 2017, over 7 years ago
Updated 12 September 2024, 4 months ago

Hi,

I have read this post ( https://www.drupal.org/node/2865107 ) when I was looking for to replace a file instead of rename. And, I have found this module.

I would like to be able to download a file with a specific name or, if not possible, an administrable custom name who will not change even if file is updated later.

This module allow to download a file with a unique url even if file is updated but the file who is really downloaded have the name of the last revision (like _0, _1 etc.). I think it could be valuable to offer an option who allow to specify the filename maybe using the "name" field of media bundle ?

What do you think ?

(sorry for my english)

Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

🇫🇷France pclaitte Toulouse

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States mortona2k Seattle

    I got a request to implement this - we want to be able to replace media files with the same filename. I'm ok with media adding _1 for versioning and caching, but it would be great if it could be downloaded with a clean filename. Generating that from the media name makes sense.

    I imagine we need this in place to get it working: https://www.drupal.org/project/media_entity_download/issues/3351543 Introduce hook to alter the download response Active
    This is a similar issue (is it a duplicate?) https://www.drupal.org/project/media_entity_download/issues/3176548

    What are the blockers here? If one of those patches works, it may not be too difficult to get the base case for this working.

  • 🇩🇰Denmark nicklasmf

    Depending on how specific we want to alter the response, if this gets approved: https://www.drupal.org/project/media_entity_download/issues/3418334 Use filename in download RTBC .

    We could also simply create a hook for the filename like:
    $filename = $this->moduleHandler()->invokeAll('file_download_name', [$media, file]);

    And then add a default return for the hook like: $filename = $file->label();

  • Status changed to Active 11 months ago
  • Status changed to Needs review 4 months ago
  • 🇮🇳India dev2.addweb

    Hi, I added JavaScript to prompt users to rename files before download and added checkbox in FieldFormatter to use this functionality. Please review the attached patch.

Production build 0.71.5 2024