Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Protected File (from download)

Security covered Under active development 341 sites

This module adds a field type that allows you to control access to files. You can choose to make specific files downloadable only by users with the correct permissions, while still displaying the file to all users. This is useful for requiring registration or specific roles before allowing file downloads.

Protected file module provide a new field type which extends File field and permit to enable/disable for each file the possibility to prevent users to download the file, if they don't have the right permission, whereas the file is still visible on the page.

This module is useful if you want to prevent users to download file, but you want display the file regardless.

REQUIREMENTS

This module provide a new field type "Protected file" based on the File field type. File is provided by Drupal core.

This module requires that the private system file is available.

SIMILAR MODULES

Field permissions permit to set permissions on fields, and then can prevent users to access to file uploaded with a File field. But users without the permissions don't see then the file attached to an entity.

Protected file permit to display every files, but can prevent users to download them. This can be useful if you want that users have to register to be able to download some (specific) file(s).

INSTALLATION

Install as you would normally install a contributed Drupal module. See:
https://www.drupal.org/documentation/install/modules-themes/modules-8
for further information.

CONFIGURATION

  • Create a "Protected file" field on an entity
  • Configure the field settings as the standard File field (directory, extension, etc.)
  • Configure the field formatter : you can specify if the file is downloaded in a new tab, the redirect path for users without permissions, if the redirect path is open inside a modal or not, and the text used for the title link. If the redirect path is empty, and user has not the permission to download the protected file, then only the name of the file, without link, is displayed
  • Configure the permissions to allow Roles to download protected file
  • Create content and upload some files. For each file you can protect them by checking the protected checkbox

You can override the twig template protected-file-link.html.twig if you want
customize the feel and look of your protected files.

By default, the module provide and inject a markup based on a fontawesome class for protected
files (fa-lock icon). This markup is available in the {{ icon }} twig variable. You can easily
override it in the template or in a preprocess fonction.

This module was sponsored by Cerema.

Drupal 10–11

Ask your assistant about Protected File (from download)

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

  • field Drupal core
  • file Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
5
Tracked since
Mar 2023
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 1
Maintenance
Slowing

Release Timeline

Releases

Version Type Core PHP Release date
2.0.1 Stable 10–11 Jun 25, 2025
2.0.0 Stable 10–11 Oct 10, 2024
2.0.x-dev Dev 10–11 Oct 10, 2024
8.x-1.5 Stable 9–10 Oct 10, 2024
8.x-1.4 Stable 9–10 Mar 19, 2023