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)

Comments

pclaitte created an issue. See original summary.

kevinquillen’s picture

Pathauto support would be nice, but I am not sure how to do that yet.

kevinquillen’s picture

Status: Active » Postponed
justaman’s picture

You just need to go to admin/structure/media/manage/file/form-display and drag the "name" field up to the visible region.

I am currently working on how to fetch that field programmatically :)

mortona2k’s picture

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
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.

NicklasMF’s picture

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

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();

NicklasMF’s picture

Status: Postponed » Active